Laracast Video(Push Events to the Client) 错误?
Laracast Video(Push Events to the Client) error?
我尝试创建事件处理...所以我遵循了这个视频教程...一切正常。但在最后一分钟的视频中,当我尝试在 列表视图 中显示用户名时,它没有像列表视图那样实时更新,但我检查了 console.log('users') 我可以从我的控制台获取每个对象....但在视图中没有更新或没有错误.........什么是错误?
这是视频教程 - LINK
<body>
<ul id="users">
<li v-repeat="user: users">@{{ user.name }}</li>
</ul>
<script src="https://js.pusher.com/3.0/pusher.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.20/vue.min.js"></script>
<script>
// (function () {
// var pusher = new Pusher('82355e6cc93e7a15d7d5', {
// encrypted: true
// });
//
// var channel = pusher.subscribe('test');
// channel.bind('App\Events\UserHasRegistered', function(data) {
// console.log(data);
// });
// })();
new Vue({
el: '#users',
data:{
users:[]
},
ready: function(){
var pusher = new Pusher('82355e6cc93e7a15d7d5', {
encrypted: true
});
pusher.subscribe('test')
.bind('App\Events\UserHasRegistered',this.addUser);
},
methods: {
addUser: function(user){
this.users.push(user);
}
}
})
</script>
</body>
v-repeat
指令在 1.0 版中已弃用并替换为 v-for
。
1.0 replaces the old v-repeat
directive with v-for
. In addition to providing the same functionality and more intuitive scoping, v-for
provides up to 100% initial render performance boost when rendering large lists and tables!
http://vuejs.org/2015/10/26/1.0.0-release/#Faster-Initial-Rendering
我尝试创建事件处理...所以我遵循了这个视频教程...一切正常。但在最后一分钟的视频中,当我尝试在 列表视图 中显示用户名时,它没有像列表视图那样实时更新,但我检查了 console.log('users') 我可以从我的控制台获取每个对象....但在视图中没有更新或没有错误.........什么是错误? 这是视频教程 - LINK
<body>
<ul id="users">
<li v-repeat="user: users">@{{ user.name }}</li>
</ul>
<script src="https://js.pusher.com/3.0/pusher.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.20/vue.min.js"></script>
<script>
// (function () {
// var pusher = new Pusher('82355e6cc93e7a15d7d5', {
// encrypted: true
// });
//
// var channel = pusher.subscribe('test');
// channel.bind('App\Events\UserHasRegistered', function(data) {
// console.log(data);
// });
// })();
new Vue({
el: '#users',
data:{
users:[]
},
ready: function(){
var pusher = new Pusher('82355e6cc93e7a15d7d5', {
encrypted: true
});
pusher.subscribe('test')
.bind('App\Events\UserHasRegistered',this.addUser);
},
methods: {
addUser: function(user){
this.users.push(user);
}
}
})
</script>
</body>
v-repeat
指令在 1.0 版中已弃用并替换为 v-for
。
1.0 replaces the old
v-repeat
directive withv-for
. In addition to providing the same functionality and more intuitive scoping,v-for
provides up to 100% initial render performance boost when rendering large lists and tables!
http://vuejs.org/2015/10/26/1.0.0-release/#Faster-Initial-Rendering