0
所以我基本上有2个脚本。处理用户登录,检查等的用户脚本。还有一个处理页面操作的脚本。现在,我希望能够显示由页面脚本控制的按钮,但只有在用户登录时才显示该按钮。此按钮位于页面脚本元素中,因此我无法通过用户脚本对其进行处理。这也会非常混乱。从其他Vue.js脚本获取数据
继承人一些代码来解释什么,我试图做:
user.js的:
var userAuth = new Vue({
el: '#userSegment',
data: { 'loggedin': false, },
ready: function(){
if(userLoggedIn){ this.loggedin = true; }else{ this.loggedin = false; }
},
});
page.js
new Vue({
el: '#body',
data: { 'buttonclicked': false, },
method: {
clicked: function(){ this.buttonclicked = true; },
},
});
的index.html:
<html>
<div id='userSegment></div>
<div id='body'>
<button v-if='userAuth.loggedIn' v-on='click: clicked()' >
Click Me
</button>
</div>
//both the script links are here. Dont worrie
</html>
但按钮没有显示当用户登录时。对不起,如果解决方案非常简单,但这个框架的文档(比如每4个5)都很糟糕并且一团糟。