# vue代码组件
this.$createElement(MinZhuResultShowComp, {
props: {
styleValue: record.style,
instanceId: this.instance.id,
normId: record.id,
objId: this.dataSource[this.activeKey]['beAssessPerson']
}
})
# 指定容器操作滚动条
this.$nextTick(() => {
const WrapperDom = document.getElementsByClassName('wrapper')[0]
setTimeout(function() {
WrapperDom.scrollTo({ top: WrapperDom.scrollHeight, behavior: 'smooth' })
}, this.durationTime * 1000)
})
# Vue动态拼接html中的方法调用问题
首先,在js中直接拼接方法,这里以pressed()
为例,然后在mounted
指定window.pressed = ()=>{}
,然后通过_this
进行方法调用
mounted() {
const _this = this
window.pressed = function(channelNum) {
_this.pressed(channelNum)
}
},
methods: {
pressed() {
alert(123)
},
addSendPromptInfo(prompt) {
this.sendHtml = '<div class="msg self">' +
'<div class="main"><div class="content bg-color shadow" onclick="pressed()">' + prompt.content.content + '</div></div>' +
'<div class="headImg" style="background-image:url(' + this.userHeaderImg + ')"></div>' +
'<div class="date">' + dayjs(prompt.sentTime).format('YYYY-MM-DD HH:mm:ss') + '</div>' +
'</div>'
this.chatMessage += this.sendHtml
}
}