vue.js从输入中的contenteditable元素获取innerhtml

<div
    class="actual-score"                                        
    :contenteditable="$route.params.mode === ‘edit‘"
    v-html="item.shijidefen"
    @input="changeVal($event)"
    @blur="verifyScore(item)"
    :class="{‘can-edit‘: $route.params.mode==‘edit‘&!item.isVerify}"
></div>        
changeVal(e) {
    this.editValue = e.target.innerHTML;
},
verifyScore(item) {
    let { subList } = item;
    let allScores = [];
    subList.forEach(subItem => {
    subItem.thirdList.forEach(thirdItem => {
        allScores.push(thirdItem.fufenzhi);
    });
    });
    if (!isPositiveInteger(this.editValue)) {
    this.$message({
        type: ‘warning‘,
        message: ‘请输入正整数‘
    });
    return;
    }
    if (allScores.includes(this.editValue)) {
    Vue.set(item, ‘isVerify‘, true);
    } else {
    this.$message({
        type: ‘warning‘,
        message: ‘实际得分包含于赋分值‘
    });
    Vue.set(item, ‘isVerify‘, false);
    }
}

 

https://cloud.tencent.com/developer/ask/182315

 

vue.js从输入中的contenteditable元素获取innerhtml

上一篇:详解mixphp的依赖注入控制反转


下一篇:SDWebImage源码分析(一)