赞
踩
vue-admin-beautiful成为全网首家发布vue3.0版本的admin框架
开源地址:https://github.com/chuzhixin/vue-admin-beautiful/
演示地址:https://chu1204505056.gitee.io/vue-admin-beautiful/
pro演示地址:https://chu1204505056.gitee.io/vue-admin-beautiful-pro/
vue3.0版演示地址:https://chu1204505056.gitee.io/vue-admin-beautiful-mini/
//组件库
https://mrhj.gitee.io/form-generator/?hmsr=vue-admin-beautiful-pro&hmpl=&hmcu=&hmkw=&hmci=#/
<div id="counter">
Counter: {{ counter }}
</div>
const Counter = {
data() {
return {
counter: 0
}
}
}
Vue.createApp(Counter).mount('#counter')
这里与之前不同的是 //Vue挂载书写采用了新的方式
new Vue({
router,
store,
render: h => h(App)
}).$mount('#app')
<div id="bind-attribute">
<span v-bind:title="message">
鼠标悬停几秒钟查看此处动态绑定的提示信息!
</span>
</div>
const AttributeBinding = {
data() {
return {
message: 'You loaded this page on ' + new Date().toLocaleString()
}
}
}
Vue.createApp(AttributeBinding).mount('#bind-attribute')
<div id="event-handling">
<p>{{ message }}</p>
<button v-on:click="reverseMessage">反转 Message</button>
</div>
const EventHandling = {
data() {
return {
message: 'Hello Vue.js!'
}
},
methods: {
reverseMessage() {
this.message = this.message
.split('')
.reverse()
.join('')
}
}
}
Vue.createApp(EventHandling).mount('#event-handling')
<div id="two-way-binding">
<p>{{ message }}</p>
<input v-model="message" />
</div>
const TwoWayBinding = {
data() {
return {
message: 'Hello Vue!'
}
}
}
Vue.createApp(TwoWayBinding).mount('#two-way-binding')
<div id="conditional-rendering">
<span v-if="seen">现在你看到我了</span>
</div>
const ConditionalRendering = {
data() {
return {
seen: true
}
}
}
Vue.createApp(ConditionalRendering).mount('#conditional-rendering')
<div id="list-rendering">
<ol>
<li v-for="todo in todos">
{{ todo.text }}
</li>
</ol>
</div>
const ListRendering = {
data() {
return {
todos: [
{ text: 'Learn JavaScript' },
{ text: 'Learn Vue' },
{ text: 'Build something awesome' }
]
}
}
}
Vue.createApp(ListRendering).mount('#list-rendering')
可以看的出来这些基础命令并没有什么变化(个人见解,与之前2.x的使用方式相同)
const app = Vue.createApp({
data() {
return { count: 4 }
}
})
const vm = app.mount('#app')
console.log(vm.count) // => 4
console.log(this.count) // => 4
—定义方法
const app = Vue.createApp({})
app.config.globalProperties.$md5 = () => {}
Vue3.0 在 Composition API 中另外加了两个钩子,分别是 onRenderTracked 和 onRenderTriggered,两个钩子函数都接收一个 DebuggerEvent :
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。