先上报错:
然后花了一早上,找到了罪魁祸首(不确定):
<template v-if="paper.type == 'article'">
<div class="content" v-html="paper.front"></div>
</template>
<template v-else>
<div class="content">
<div class="block" v-for="photo in paper.front">
<div class="img" v-bind:style="{'background-image': 'url(' + photo.url + ')'}"></div>
<div class="remark">➢ {{photo.remark}}</div>
</div>
</div>
</template>
注意if...else,如果去掉else,改成下面这样,就OK了:
<template v-if="paper.type == 'article'">
<div class="content" v-html="paper.front"></div>
</template>
<template v-if="paper.type == 'photo'">
<div class="content">
<div class="block" v-for="photo in paper.front">
<div class="img" v-bind:style="{'background-image': 'url(' + photo.url + ')'}"></div>
<div class="remark">➢ {{photo.remark}}</div>
</div>
</div>
</template>
但是百思不得其解,报错的原因是什么?正常的原因又是什么?
template v-if和单纯的v-if指令是不同的。
https://cn.vuejs.org/v2/guide...
升级最新的Vue.js可解决这个Bug,233333