that.tplStr = that.readFile(’/template/’ + moduleName + ‘/’ + formType + ‘.html’)
that.$refs.formBody.buildForm(that.tplStr, that.fieldsList, that.buttonsList,res.data.subList,res.data.subListData
//读取模板数据
readFile(filePath) {
// 创建一个新的xhr对象
let xhr = null
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest()
} else {
// eslint-disable-next-line
xhr = new ActiveXObject(‘Microsoft.XMLHTTP’)
}
const okStatus = document.location.protocol === ‘file’ ? 0 : 200
xhr.open(‘GET’, filePath, false)
xhr.overrideMimeType(‘text/html;charset=utf-8’)
xhr.send(null)
return xhr.status === okStatus ? xhr.responseText : null
}
vue模板文件使用的方法
于 2022-02-17 09:54:50 首次发布