<template>
<div id="app">
<button type="button" @click="increment">count值:{{ state.count }}</button>
</div>
</template>
<script>
export default {
//name: 'HelloWorld',
app.component('HelloWorld'),{
props: ['Hello'],
setup(){
const state = Vue.reactive({count:0});
function increment(){
state.count++;
}
return {
state,
increment
}
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
又一个错的
<template>
<div id="app">
<button type="button" @click="increment">count值:{{ state.count }}</button>
</div>
</template>
<script>
import { reactive } from 'vue'
export default {
name: 'HelloWorld',
app.component('HelloWorld'),{
props: ['Hello'],
setup(){
const state = Vue.reactive({count:0});
function increment(){
state.count++;
}
return {
state,
increment
}
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>