我有一个从服务器发送的html块,我想从嵌入在该html中的链接调用方法或函数。Vue.js从动态html调用方法
在我.vue文件,该HTML被显示,像这样:
import axios from 'axios'
export default {
data() {
return {
myhtml: null
}
},
created() {
this.refreshHTML()
},
methods: {
refreshHTML() {
axios.get()// get my html
this.myhtml = response.data
},
myFunction() {
//do my function stuff here...
}
}
}
什么我想这是牵强的HTML做的是附上触发我的功能,像这样一个onclick事件:
但是当我尝试,我得到:
ReferenceError: Can't find variable: myFunction
2017-09-24
Stephen
+0
你也可以做这样的事情:https://codepen.io/Kradek/pen/zEopZd?editors=1010 –