Git Product home page Git Product logo

Comments (8)

Rowandjj avatar Rowandjj commented on May 17, 2024

@Z-Janp ,You should install weex-bindingx by:

npm install weex-bindingx --save

and then you can import&use it:

import BindingX from weex-bindingx;
...
BindingX.bind();

from bindingx.

zhangjanp avatar zhangjanp commented on May 17, 2024

@Rowandjj yeah, I did do that.
"typeof callNative !== 'function'" which is inside the package
node_modules/universal-env/lib/index.js

from bindingx.

Rowandjj avatar Rowandjj commented on May 17, 2024

@Z-Janp well, so the problem is universal-env#isWeex return false ?

as far as I know, in the latest version of weex,callNative is moved,so you cannot use that to determine whether weex is exists or not. Instead you should use WXEnvironment .

The newest version of universal-env has already solved the problem:

//https://github.com/alibaba/rax/blob/master/packages/universal-env/src/index.js
export const isWeex = typeof callNative === 'function' || typeof WXEnvironment === 'object';

So update universal-env should solve the problem. Or you can degrade your weex_sdk to the old version too.

Hope it helps, ths:)

====
updated:
btw, universal-env is designed for rax and should not use in vue.

from bindingx.

zhangjanp avatar zhangjanp commented on May 17, 2024

Yes, that is what I want to express.
but, I found that weex-bindingx relies on universal-env.
And, I have upgraded universal-env. But they haven't pushed the latest code to the npm repository.
I'm just wondering why weex-bindingx depends on universal-env.
Your answer is helpful.
Thx u!!!

from bindingx.

Rowandjj avatar Rowandjj commented on May 17, 2024

@Z-Janp In fact weex-bindingx is not rely on universal-env at all.

Because we have a web polyfill version of bindingx which can run on browser, however, findDomNode API is difference between weex and web. So you can see this function in our demos:

function getEl(el) {
  return isWeex ? findDOMNode(el).ref : findDOMNode(el);
}

=====

As for your problem, there are some ways to go out:

  1. Use universal-env#isWeb variable to do the same thing.
  2. Implement isWeex yourself
     let  isWeex = typeof callNative === 'function' || typeof WXEnvironment === 'object';
    
  3. If you do not need to compatible with html5, just remove isWeex.

ths:)

from bindingx.

zhangjanp avatar zhangjanp commented on May 17, 2024

I see.
But, This is not work.
let isWeex = typeof callNative === 'function' || typeof WXEnvironment === 'object';

in the latest version of weex,callNative is moved
Similarly, there is no callNative on the web.

But, WXEnvironment is a valid object in the web.
so...This kind of judgment logic is problematic.

from bindingx.

Rowandjj avatar Rowandjj commented on May 17, 2024

@Z-Janp umm, I found that too. The Rax team will figure that out later.

For now, use isWeb maybe the best option for you.

from bindingx.

zhangjanp avatar zhangjanp commented on May 17, 2024

ok, thx again!

from bindingx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.