如何在 Vue JS <td> 表标签中正确使用 v-if 和 v-else

Eem*_*Jee 3 html-table vue.js

由于我的搜索是不够的我的问题,我在这里张贴有关于如何正确使用一些澄清v-if,并v-else<td>在VUE在HTML表格标记。

//given the value of this.property is name
<tr>
    <td v-if="this.property == 'name'">I'm name</td>
    <td v-else>No I'm not</td>
</tr>
Run Code Online (Sandbox Code Playgroud)

我的问题是,即使我的this.property值是'name'不是a'name'它总是符合v-else条件,并且v-if不会被执行。我想要的输出是执行v-if如果this.property值是'name'v-else如果不是。

我这样做是正确的吗?我在这里需要你的指导。

Har*_*til 6

删除this指针。你不需要它。

//given the value of this.property is name
<tr>
    <td v-if="property === 'name'">I'm name</td>
    <td v-else>No I'm not</td>
</tr>
Run Code Online (Sandbox Code Playgroud)