Bugs with "v-if"
larrymacbarry opened this issue · comments
If you are using one data variable for conditional render by "v-if" for two elements, it crashes on change:
<template>
<Window title="vuido-project" width="400" height="100" margined v-on:close="exit">
<Box>
<Text>Press the button!</Text>
<Text v-if="!buttonIsOn">Thanks!</Text>
<Button v-on:click="buttonOn" v-if="buttonIsOn" >Ok</Button>
</Box>
</Window>
</template>
<script>
import libui from 'libui-node'
export default {
data: function () {
return {
buttonIsOn: true
}
},
methods: {
exit() {
libui.stopLoop();
},
buttonOn() {
console.log(this.buttonIsOn);
this.buttonIsOn = false;
}
}
}
</script>
[Vue warn]: Error in nextTick: "Error: Child node already has a parent"
(node:6216) UnhandledPromiseRejectionWarning: Error: Child node already has a parent...
But if you using different variables it works:
<template>
<Window title="vuido-project" width="400" height="100" margined v-on:close="exit">
<Box>
<Text>Press the button!</Text>
<Text v-if="buttonIsOn1">Thanks!</Text>
<Button v-on:click="buttonOn" v-if="buttonIsOn" >Ok</Button>
</Box>
</Window>
</template>
<script>
import libui from 'libui-node'
export default {
data: function () {
return {
buttonIsOn: true,
buttonIsOn1: true
}
},
methods: {
exit() {
libui.stopLoop();
},
buttonOn() {
console.log(this.buttonIsOn);
this.buttonIsOn = false;
this.buttonIsOn1 = false;
}
}
}
</script>
I can confirm that this is a bug, I will fix it soon.