vue各种字符串拼接方式
作者:w_t_y_y
这篇文章主要介绍了vue各种字符串拼接方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教
vue各种字符串拼接
1、文件绑定{{}}中的字符串拼接
直接在{{}}内拼接:
<template v-if="userList">
<div v-for="(item,index) in userList" :key="index">
{{item.userName+'('+item.userAccount+')'}}
</div>
</template><el-option
v-for="item in projectList"
:key="item.pNo"
:label='`${item.name}-${item.managerName}(${item.managerAccount})`'
:value="item.pNo"
>
</el-option>:ref="`user${index}`"2、vue标签属性绑定中的字符串拼接
写法有两种:
- :title="`字符串${xx}`"
- :title="'字符串' + xx" 都可以
其中,{}里面可以写js方法。
如:
<el-option
v-for="item in tableData"
:key="item.account"
:label= '`${item.name}${item.account}`'
:value="item.account"
:height = "schoolHeight">
</el-option><el-submenu v-show="item.childList.length > 0" :index="item.id" :class='`menu${item.id}`'><span :class="{ red: originData[`${item.value}ChangeFlag`] }">{{ item.text }}</span>3、js中的字符串拼接
this.personList.forEach(item => {
item.label = `${item.userName}(${item.account})`;
});this.$bus.$emit(`${this.activeName}-reload`, this.searchData);switchStatus(row) {
this.$Modal.confirm({
title: '提示',
content: `是否确认切换状态为${row.isDelete === 1 ? '否' : '是'}?`,
onOk: () => {
row.isDelete = row.isDelete === 0 ? 1 : 0;
}
});
},总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
