vue各种字符串拼接
写法有两种::title="`字符串${xx}`" 或 :title="'字符串' + xx" 都可以。如:1、vue绑定值与字符串拼接:<el-optionv-for="item in tableData":key="item.account":label= '`${item.name}${item.account}`':value=...
文章共379字 · 阅读需要大约2分钟
一键AI生成摘要,助你高效阅读
问答
·
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;
}
});
},
更多推荐
已为社区贡献9条内容
所有评论(0)