Composition API 纯函数式
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <div id="app"></div> <script src="vue.global.js"></script> <script> // Composition API const App = { setup () { let state = Vue.reactive({name: ‘wyq‘, age: 18}); const other = function () { console.log(‘111‘); state.name = ‘点击了‘ }; Vue.onMounted(() => { console.log(‘dom加载完了‘) }); Vue.effect(() => { console.log(state.name) }) return { state, other } }, template: `<div @click="other">{{state.name}}</div>`, } Vue.createApp().mount(App, app) </script> </body> </html>
ts实现类型推断 函数式编程 响应式才是核心
原文地址:https://www.cnblogs.com/QQPrincekin/p/11972401.html
时间: 2024-11-06 11:45:12