Skip to content

Instantly share code, notes, and snippets.

@gu-fan
Last active May 10, 2019 10:55
Show Gist options
  • Save gu-fan/f3716737cd66615582380b24a1752cb8 to your computer and use it in GitHub Desktop.
Save gu-fan/f3716737cd66615582380b24a1752cb8 to your computer and use it in GitHub Desktop.
<template>
<div>
parent {{ data.test }}
<TextDemo :pass_string="data.test" @change="onChange" />
</div>
</template>
<script>
// pages/demo/index.vue
import TextDemo from '@/components/TextDemo'
export default {
components: {
TextDemo,
},
data(){
return {
data:{
test: 'hhhh',
},
}
},
methods:{
onChange(e){
console.log('got', e)
this.data.test = e
},
}
}
</script>
<style lang="stylus">
</style>
<template>
<div >
child: {{pass_string}}
<textarea
v-model="pass_string"
@input="onChange"
style="background:red;"
></textarea>
</div>
</template>
<script>
// components/TextDemo.vue
export default {
props:['pass_string'],
methods:{
onChange(e){
console.log(e)
this.$emit("change", e.mp.detail.value)
},
}
}
</script>
<style lang="stylus">
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment