公共/ JS/symp.js(初始后)Laravel 5.3,Vue.js 2+不能得到列表呈递(V-的)工作
资源/视图/ dash.blade.php (初始后)
<html>
<body>
@extends('layouts.app') [ this includes symp.js and calls @yeild('content') ]
@section('content')
<div id="symp">
<div>
<span>subject</span>
<span>message</span>
</div>
tease: <span>@{{ tease }}</span>
<div v-for="item in items">
sub: <span>@{{ item.subject }}</span>
msg: <span>@{{ item.message }}</span>
</div>
</div>
@endsection
我知道Laravel与{{}}等需要预先@打架,但我的理解是上面的演示代码段应出示挑逗:先测试后两排
子:一个信息: Foo
sub:B msg:Bar
...唉,我看到了戏弄:主题消息,没有戏弄价值,并且根本没有行。
什么是搞笑的,我有一个文件夹作为我正在建立的项目的一部分,工作版本为http://www.hc-kr.com/2016/11/laravel-5-vuejs-crud-with-notification-pagination-laravel.html,但是该文件夹强制Vue.js 1.x,所以看起来这是Laravel 5.3的独特问题的vue.js 2.x?
[更新每@PanJunjie潘俊杰建议:-)]
资源/视图/ dash.blade.php
@extends('layouts.app')
@section('content')
<div id="symp">
</div>
@endsection
资源/视图/布局/ app.blade.php
<html>
<script src="/js/app.js"></script>
<body>
...
<template id="symp-temp">
tease: <span>@{{ tease }}</span>
<div v-for="item in items">
sub: <span>@{{ item.subject }}</span>
msg: <span>@{{ item.message }}</span>
</div>
</template>
</body>
<script src="/js/symp.js"></script>
</html>
公共/ JS/symp.js
new Vue({
el :'#symp',
name: 'symp', /* unnecessary? */
template: '#symp-temp', /* this helps a bit :-) */
data :{
tease: 'well',
items: [
{ message: 'Foo', subject: 'A' },
{ message: 'Bar', subject: 'B' }
]
}
});
一些进展。现在显示的是逗号值,但项目行仍然不显示。 JavaScript控制台报告这个...
[Vue warn]: Component template should contain exactly one root element:
tease: <span>{{ tease }}</span>
<div v-for="item in items">
sub: <span>{{ item.subject }}</span>
msg: <span>{{ item.message }}</span>
</div>
我使用单一的.vue(#3)更成功,但它并不理想。真的很困惑,为什么这段代码与最新的vue.js差得很厉害 – rickatech
实际上也排序了#1(看下面):-) 谢谢! – rickatech