Hello Vue.js
``` 或者 ```vueHello Vue.js
``` 相关知识点:[单文件组件 CSS 功能 | Vue.js](https://staging-cn.vuejs.org/api/sfc-css-features.html) ## Components ### DOM 传送门 见上面 ### Props 验证 验证 Button 组件的 Prop 类型 ,使它只接收: primary | ghost | dashed | link | text | default ,且默认值为 default ```vue ``` 相关知识点:[Props | Vue.js](https://staging-cn.vuejs.org/guide/components/props.html#prop-validation) ### 函数式组件 这题我不是很懂,翻了一下大家的解决方案,感觉这个比较能看懂:[21 - functional component · Issue #322 · webfansplz/vuejs-challenges · GitHub](https://github.com/webfansplz/vuejs-challenges/issues/322) ```vueState: {{ state ? 'ON' : 'OFF' }}
Toggle state
``` ### 计数器 实现一个计数器 ```vue ``` ### 实现本地存储函数 封装一个`localStorage`API ```vueCounter: {{ counter }}
``` 相关知识点: - [watchEffect()](https://staging-cn.vuejs.org/api/reactivity-core.html#watcheffect) - [Window.localStorage - Web API 接口参考 | MDN](https://developer.mozilla.org/zh-CN/docs/Web/API/Window/localStorage) ### 鼠标坐标 这个没通过单元测试,不知道什么原因,试了下其他人的也没能通过…… ```vue Mouse position is at: {{ x }}, {{ y }} ``` ## Composition API ### 生命周期钩子 ```vueChild Component: {{ count }}
- {{ count }} +
- {{ count }} +
{{ count }}
{{ plusOne }}
{{ count }}
{{ age }}
{{ state.count }}
{{ doubled }}
{{ value }}
``` ## Event Handling ### 阻止事件冒泡 ```vue{{ reactiveState.count }}
Increase
``` ## Web Components ### 自定义元素 ```vue ``` 并且 vite.config.js 里要做相关设置 相关知识点:[Vue 与 Web Components | Vue.js](https://staging-cn.vuejs.org/guide/extras/web-components.html)