wft-utils
Version:
The commonly used tool functions in daily development
60 lines (59 loc) • 1.34 kB
HTML
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mini Vue</title>
</head>
<body>
<div id="app"></div>
<script src="./lib/render.js"></script>
<script src="./lib/reactive_v2.js"></script>
<script src="./lib/create_app.js"></script>
<script>
// 1.创建跟组件
const App = {
data: reactive({
counter: 0
}),
render() {
return h('div', { class: 'WFT' }, [
h('button', {
onClick: () => {
this.data.counter--
console.log(this.data.counter)
}
}, '-1'),
h('h2', null, `当前计数:${this.data.counter}`),
h('button', {
onClick: () => {
this.data.counter++
console.log(this.data.counter)
}
}, '+1')
])
}
}
// 2.挂载跟组件
const app = createApp(App)
app.mount('#app')
</script>
<style>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
.WFT {
display: flex;
margin: 20px 0 0 20px;
}
h2 {
margin: 0 10px;
}
button {
padding: 5px 15px;
}
</style>
</body>
</html>