You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TypeError: Cannot read property 'fullPath' of undefined
at Object.useInit (useInit.js? [sm]:13)
at setup (year.js:8)
at callWithErrorHandling (vendor.js? [sm]:2843)
at setupStatefulComponent (vendor.js? [sm]:4977)
at setupComponent (vendor.js? [sm]:4941)
at mountComponent (vendor.js? [sm]:5481)
at createComponent3 (vendor.js? [sm]:5703)
at $createComponent (vendor.js? [sm]:6691)
at pi.attached (vendor.js? [sm]:6783)
at o.safeCallback (WASubContext.js?t=wechat&s=1696819033492&v=3.1.2:1)(env: Windows,mp,1.06.2307260; lib: 3.1.2
在作者给出的test示例中,对于
useInit
是这样使用的:onLoad(() => { const { pageName, pagePath, pageQuery } = useInit(); console.log(pageName, pagePath, pageQuery, 'pageName,pagePath, pageQuery'); });
此时存在问题:
解构出来的变量只允许在 onLoad 作用域中使用,无法提供给
template
使用。 我尝试过将onLoad
生命周期也放入 useInit 进行管理,但出现了很奇怪的bug,最后失败了。有没有更好的解决方案呢?我希望解构出来的变量可以在
setup
下作为全局变量使用,而不是只能在onLoad
中使用的局部变量The text was updated successfully, but these errors were encountered: