Registering a Vue mixin in `src/entry.js` does not seem to work
Hi,
I initialised a weex and vue app using weex create awesome-project. In the entry.js file I am trying to register a global mixin but it does not seem to be registering. The file code is is:
import weex from 'weex-vue-render'
import Vue from 'vue'
Vue.mixin({
computed: {
device () {
return 'mobile'
},
browser () {
return this.device === 'browser'
},
mobile () {
return this.device === 'mobile'
}
}
})
weex.init(Vue)
none of the components seem to have this.mobile as true. Works fine in the web simulator but not when I scan the QR code on my phone.
issue was with a broken ver of weex, fixe by updating.
me too,But I'm using the latest version
@linda8167 @tuqire 请问如何解决的,我这里也试了,不可以。 Vue.mixin不行。。编译完的js代码没有包含Vue.mixin()
@linda8167 @pcwang0205 请问你们是怎么解决的?
@starfalling 每个vue文件单独引用吧
我们后面在native端做了这个变量注入了,也不知道用法上是对还是不对,weex的文档太简略了
变量注入和mixin有啥关系?不一样吧
目前只是注入变量,方便直接在 template 里面引用,省得每个 vue 文件都在 data 或者 computed 里面写一道。变量注入跟 mixin 当然是不一样的,不过暂时没有找到什么好的方法去用这个 mixin。weex环境下,不能在代码里面写 import vue,如果import了会导致编译出来的 JS 文件大很多,不 import 没办法调用 Vue 的函数
@pcwang0205 你们还在用 weex 么?刚尝试用半个月,坑好多
嗯。mixin这样用

那还是得每个文件都要写一道了,不过这个比每个vue文件都写一遍要强了,没有文档全靠摸索,可以加个QQ交流么?
@starfalling qq: 823312251