onclick 执行的是 window 环境中的方法,所以:将 this 中的方法或data中定义的字段关联到 window 上即可。
vue代码
mounted () { window.customMethods = this.customMethods}, //把方法定义到window对象上
methods:{
customMethods(){
alert(666)
}
},
html代码
<div class="poster_inner" onclick="javascript:customMethods()">
</div>
data中的数据是一样的道理,data数据赋值完成之后跟一个
window.arr = this.arr