-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
this.$on,this.$emit,this.$off 跨页面没效果 #32
Comments
是在组件中使用 this.$emit 然后在其他页面使用 this.$on进行监听,但在其他页面中this.$on 没有触发。 |
能确认 |
|
现在已经可以了 谢谢大大 |
require('./lib/wxpage').A({
|
感觉是和.A有关 但去掉的话 又会报其他错误。。
|
能展示下在哪个生命周期使用,与及完整的报错信息吗 |
require('./lib/wxpage').A({ extendPageBefore: function (name, page) { page.$global = function (key, value) { var len = arguments.length if (len > 1) { getApp().globalData[key] = value } else if (len == 1) { return getApp().globalData[key] } else { return getApp().globalData } } }, globalData:{ test:'111' }, config: { route: '/pages/$page', }, onLaunch: function(opts) { // console.log('APP is Running', opts) }, onShow: function () { // Do something }, })
var P = require('../lib/wxpage'); P('index', { ... onLoad:function(){ console.log(this.$global('test')); ...
VM644:1 thirdScriptError this.$global is not a function;at pages/index page lifeCycleMethod onLoad function TypeError: this.$global is not a function at s.onLoad (http://127.0.0.1:13134/appservice/pages/index.js:22:20) at s. (http://127.0.0.1:13134/appservice/lib/wxpage.js:275:17) at s. (http://127.0.0.1:13134/appservice/lib/wxpage.js:275:17) at s. (http://127.0.0.1:13134/appservice/__dev__/WAService.js:1:696239) at s.__callPageLifeTime__ (http://127.0.0.1:13134/appservice/__dev__/WAService.js:1:696012) at Vt (http://127.0.0.1:13134/appservice/__dev__/WAService.js:1:714681) at Ht (http://127.0.0.1:13134/appservice/__dev__/WAService.js:1:715708) at Kt (http://127.0.0.1:13134/appservice/__dev__/WAService.js:1:717001) at Function. (http://127.0.0.1:13134/appservice/__dev__/WAService.js:1:718111) at pt. (http://127.0.0.1:13134/appservice/__dev__/WAService.js:1:683214) |
A({
config: {
extendPageBefore: function (def, { fns }) {
// ...
}
}
}); |
|
extendPageBefore 是页面注册前执行,def是页面配置对象,可以往 def 挂载页面类方法(示例无关),你的用法是对的,只不过升级后 extendPageBefore 本来与 config同一层级,挪到了config里面 |
No description provided.
The text was updated successfully, but these errors were encountered: