代码拉取完成,页面将自动刷新
<template>
<div>
<input v-model="msg">
<p>prop: {{ propMessage }}</p>
<p>msg: {{ msg }}</p>
<p>helloMsg: {{ helloMsg }}</p>
<p>computed msg: {{ computedMsg }}</p>
<Hello ref="helloComponent" />
<World />
<p>
<button @click="greet">Greet</button>
</p>
<p>
Clicked: {{ count }} times
<button @click="increment">+</button>
</p>
</div>
</template>
<script lang="ts">
import Vue from 'vue'
import Component from '../../lib/index'
import Hello from './components/Hello.vue'
import World from './components/World'
import { mapState, mapMutations } from 'vuex'
// We declare the props separately
// to make props types inferable.
const AppProps = Vue.extend({
props: {
propMessage: String
}
})
@Component({
components: {
Hello,
World
},
// Vuex's component binding helper can use here
computed: mapState([
'count'
]),
methods: mapMutations([
'increment'
])
})
export default class App extends AppProps {
// inital data
msg: number = 123
// use prop values for initial data
helloMsg: string = 'Hello, ' + this.propMessage
// annotate refs type
$refs!: {
helloComponent: Hello
}
// additional declaration is needed
// when you declare some properties in `Component` decorator
count!: number
increment!: () => void
// lifecycle hook
mounted () {
this.greet()
}
// computed
get computedMsg () {
return 'computed ' + this.msg
}
// method
greet () {
alert('greeting: ' + this.msg)
this.$refs.helloComponent.sayHello()
}
// direct dispatch example
incrementIfOdd () {
this.$store.dispatch('incrementIfOdd')
}
}
</script>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。