第一种方式就是直接使用
<div>

</div>
后来因为需要写菜单图标
这是一个二级菜单,下面还有一级,图标是需要根据数据发生变化的 于是我定义数据,并作判断
if (this.clickIndex == "0") {
this.icon[0] = "";
this.icon[1] = "";
this.icon[2] = "";
this.icon[3] = "";
this.icon[4] = "";
this.icon[5] = "";
} else if (this.clickIndex == "1") {
this.icon[0] = "";
this.icon[1] = "";
this.icon[2] = "";
this.icon[3] = "";
this.icon[4] = "";
this.icon[5] = "";
this.icon[6] = " ";
} else {
}
然后再使用{{ }}引用
最后是显示字符串 并没有转义
于是我仔细查询各种资料,终于研究出方法
使用v-html
<span class="iconfont" v-html="icon[index]"> </span>
这样图标就能实现出来了