Vue.js v-if内模板道具
所以我有这个设置,我有一个名为dataviewer.vue的组件,用于显示表Vue.js v-if内模板道具,vue.js,vuejs2,vue-component,Vue.js,Vuejs2,Vue Component,所以我有这个设置,我有一个名为dataviewer.vue的组件,用于显示表 <template> <table class="table"> <thead class="bg-primary"> <tr> <th v-for="item in thead"> <span>{{item.title}}</span>
<template>
<table class="table">
<thead class="bg-primary">
<tr>
<th v-for="item in thead">
<span>{{item.title}}</span>
</th>
</tr>
</thead>
<tbody>
<slot v-for="item in model.data" :item="item"></slot>
</tbody>
</table>
</template>
<script>
import Vue from 'vue'
import axios from 'axios'
export default {
props: ['source', 'thead'],
data() {
return {
model: {
data: []
},
}
},
beforeMount() {
this.fetchData()
},
methods: {
fetchData() {
var vm = this
axios.get(this.source)
.then(function(response) {
Vue.set(vm.$data, 'model', response.data.model)
})
.catch(function(error) {
console.log(error)
})
}
}
}
</script>
但当我运行它时,它只是为所有行渲染取消图标。。。所以我的问题是如何在它里面做v-if?我也在考虑使用computed属性,但我无法从脚本获取访问权限
props.item.publish
props.item.publish
应该是整数,而不是字符串
<i class="icon-checkmark5" v-if="props.item.publish === 0"></i>
props.item.publish应为整数,而不是字符串
<i class="icon-checkmark5" v-if="props.item.publish === 0"></i>
是props.item.publish
字符串还是整数?也许只是数据类型的不匹配让你想到了另一个部分哦哇,现在你提到了,我多傻啊。。。。我去掉了引号,一切正常。。。英雄联盟非常感谢manThanks,我添加它作为答案,然后是props.item.publish
字符串或整数?也许只是数据类型的不匹配让你想到了另一个部分哦哇,现在你提到了,我多傻啊。。。。我去掉了引号,一切正常。。。英雄联盟非常感谢你,曼坦克斯,我现在加上它作为答案
<i class="icon-checkmark5" v-if="props.item.publish === 0"></i>