vue-krpano
vue-krpano copied to clipboard
communication doesn't work
Hey, I just try krpano script and vue.js communication. And it doesn't work.
methods:{ doSomething(){ //do something console.log("doSomething"); } }
There's no log show in console.
create a hook object on your view model
{
hooks: {
doSomething(){
console.log("do something)
}
}
}
assign the hooks object in your component markup
<krpano :hooks="hooks" ></krpano>
@chshapple It works! Thanks!😃
@chshapple
How can I get the vue instance in doSomething() function? Now the 'this' in doSomething() function is an object, not vue instance.
{ hooks: { doSomething(){ console.log(this) console.log("do something") } } }
@zhuyuanwen
export default {
data () {
const vm = this;
return {
hooks: {
doSomething () {
console.log(vm) //not this
}
}
}
}
}