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;
        }
      });
    },

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐