apache / incubator-weex

Apache Weex (Incubating)
https://weex.apache.org
Apache License 2.0
13.75k stars 1.82k forks source link

Load External JavaScript into Weex on Android #3125

Closed donwilly2010 closed 4 years ago

donwilly2010 commented 4 years ago

Makes sure these boxes are checked befor submitting your issue - thank you!

[Yes] If you encounter any problems using the tool, please check if there has a new version to update(Run weex update [pluginname]@latest). [Yes] Check the FAQ, make sure there have not the same issue.

Weex is a fantastic Framework for Mobile development. But I need help while trying to load an external javascript page. this page will also need some parameters from props/data. This is required for payment integration such as loading a paypal card payment page into weex.

I tried using the following but it didnt work on Weex on Android:

var document=weex.document;

method: { loadPaymentPanel(){ var body = document.createElement('div', { classStyle: { alignItems: 'center' } })

            var  script = document.createElement('script', {
                attr: { src: 'url of payment gateway' },
                classStyle: { alignItems: 'center'}
            })

body.appendChild(script) document.documentElement.appendChild(body)

paymentOptions = { amount : 2000, user: "mark", email: "mark@email.com, }

var window = document.getElementById(script).contentWindow

var handler = window.PaymentPop.setup(paymentOptions) if (!this.embed) { handler.openIframe() } }

}

*I got error the createElement is not a function.

*Please how else can I achieve what I want??

cnryb commented 4 years ago

Integrating their SDK is more suitable in the app, if you want to use PayPal to pay on the app. such as Android
https://github.com/paypal/PayPal-Android-SDK https://github.com/braintree/braintree_android

donwilly2010 commented 4 years ago

Why did you close my issue without responding to my question??

The whole essense if using weex is to avoid using android SDK.

My question is not about PayPal. I never mentioned PayPal in my post. Please note that loading an external JavaScript into a JavaScript based framework such as Weex is a very key functionality. My question is how do we load an external JavaScript using document.createElement

or how can I do it if I can't use document??