1、自定义局部文字颜色,话不多说直接上代码。dangerouslyUseHTMLString: true,这个属性一定要有,要不不生效。
confirmBoxFail() {
const reportableIndicators = `<span class="common-color-red">${this.reportableIndicators}</span>`;
const successIndicators = `<span class="common-color-green">${this.successIndicators}</span>`;
const failIndicators = `<span class="common-color-gray">${this.failIndicators}</span>`;
const result =
`<br><span class="common-color-blue" style="cursor: pointer;" onClick="matchinResult()">点击查看匹配结果</span>`
const word = `<br><span>请检查文件名称是否与指标项一致,并重新上传。</span>`
this.$confirm(
`上传文件 ${reportableIndicators} 个,匹配成功 ${successIndicators}个,未匹配成功 ${failIndicators} 个,${word}${result}`,
`一键上传`, {
confirmButtonText: "确定",
type: "warning",
dangerouslyUseHTMLString: true,
}).then(() => {
this.$refs.upload.fileList = []
});
},
2、点击事件
mounted() {
window.matchinResult = function() {
that.matchinResult();
}
},
matchinResult() {
alert('匹配结果')
}