<script>
export default {
data() {
return {
option:[]
}
},
mounted(){
setTimeout(()=>{
this.option.push(1);
},1000)
},
methods:{
sayHello(a){
uni.showToast({
title:点击了${a}
})
}
}
}
</script>
<script module="echarts" lang="renderjs">
let instance = null;
export default {
mounted() {
setTimeout(()=>{
console.log(this.$ownerInstance)
},1000)
window.onClickTest = (a)=>{
console.log(this.$ownerInstance)
instance.callMethod('sayHello',a)
}
let echarts = document.getElementById("echarts");
echarts.innerHTML = `<button type="button" onclick="onClickTest(45)">点我试一试</button>`
},
methods: {
changeData(v,old,oi){
console.log(v,old,oi)
if(!instance){
instance = oi
}
}
}
}
</script>
1 个回复
zZZ1Ma
setup 里 defineExpose 试试?