当前位置: 首页 > news >正文

哪个网站做黄金交易最好转载到wordpress

哪个网站做黄金交易最好,转载到wordpress,网站内容建设和运营工作,网上购物平台有哪些第Ⅷ章-Ⅱ 组合式API使用 provide与inject的使用vue 生命周期的用法编程式路由的使用vuex的使用获取DOM的使用setup语法糖setup语法糖的基本结构响应数据的使用其它语法的使用引入组件的使用 父组件传值的使用defineProps 父传子defineEmits 子传父 provide与inject的使用 pro… 第Ⅷ章-Ⅱ 组合式API使用 provide与inject的使用vue 生命周期的用法编程式路由的使用vuex的使用获取DOM的使用setup语法糖setup语法糖的基本结构响应数据的使用其它语法的使用引入组件的使用 父组件传值的使用defineProps 父传子defineEmits 子传父 provide与inject的使用 provide 与 inject 是 Vue 3 中用于跨组件树传递数据的 API适合解决深层嵌套组件的通信问题。 provide父组件提供数据。inject子组件接收数据。 !-- src/App.vue -- templatedivProviderComponent //div /templatescript setup import ProviderComponent from ./components/ProviderComponent.vue; /script!-- src/components/ProviderComponent.vue -- templatedivh1Provider Component/h1ChildComponent //div /templatescript setup import { provide } from vue; import ChildComponent from ./ChildComponent.vue;const providedData Hello from Provider!; provide(message, providedData); /script!-- src/components/ChildComponent.vue -- templatedivh2Child Component/h2p{{ message }}/p/div /templatescript setup import { inject } from vue;const message injectstring(message, Default Message); /scriptvue 生命周期的用法 Vue 3 引入了组合式 API使得生命周期钩子以函数形式使用增加了灵活性。 templatediv{{ message }}/div /templatescript setup langts import { ref, onMounted, onBeforeUnmount } from vue;const message ref(Hello, Vue 3!);onMounted(() {console.log(Component is mounted);message.value Component Mounted; });onBeforeUnmount(() {console.log(Component is about to unmount); }); /script 编程式路由的使用 Vue Router 支持编程式路由跳转可以使用 router.push 和 router.replace。 !-- src/components/NavigationComponent.vue -- templatedivbutton clickgoToHomeGo to Home/buttonbutton clickreplaceWithAboutReplace with About/buttonbutton clickgoBackGo Back/button/div /templatescript setup import { useRouter } from vue-router;const router useRouter();const goToHome () {router.push(/home); };const replaceWithAbout () {router.replace(/about); };const goBack () {router.go(-1); }; /scriptvuex的使用 Vuex 是 Vue 官方的状态管理库通常使用 createStore 创建全局 store。 // src/store/index.ts import { createStore } from vuex;interface State {count: number; }const store createStoreState({state: {count: 0},mutations: {increment(state) {state.count 1;},decrement(state) {state.count - 1;}},actions: {incrementAsync({ commit }) {setTimeout(() {commit(increment);}, 1000);}},getters: {doubleCount(state) {return state.count * 2;}} });export default store;在组件中使用 Vuex 状态和方法 !-- src/components/CounterComponent.vue -- templatedivh2Counter Example/h2pCount: {{ count }}/ppDouble Count (getter): {{ doubleCount }}/pbutton clickincrementIncrement/buttonbutton clickdecrementDecrement/buttonbutton clickincrementAsyncIncrement Async/button/div /templatescript setup langts import { computed } from vue; import { useStore } from vuex;const store useStore();const count computed(() store.state.count); const doubleCount computed(() store.getters.doubleCount); const increment () store.commit(increment); const decrement () store.commit(decrement); const incrementAsync () store.dispatch(incrementAsync); /script获取DOM的使用 在组合式 API 中可以使用 ref 和 onMounted 钩子来访问 DOM 元素。 templatedivinput typetext refinputElement placeholderType something... /button clickfocusInputFocus Input/button/div /templatescript setup langts import { ref, onMounted } from vue;const inputElement refHTMLInputElement | null(null);const focusInput () {inputElement.value?.focus(); };onMounted(() {console.log(Component Mounted and DOM is ready); }); /scriptsetup语法糖 setup 语法糖 在 Vue 3.3 中引入它简化了 setup 函数的使用使得代码更加简洁易读。 setup语法糖的基本结构 templatediv{{ message }}/divbutton clickincrementIncrement: {{ count }}/button /templatescript setup import { ref } from vue;const message ref(Hello, Vue 3!); const count ref(0);const increment () {count.value; }; /script响应数据的使用 ref创建单一响应式值。reactive创建响应式对象。toRefs将 reactive 对象转换为 ref 对象。 templatedivp{{ message }}/ppCounter: {{ count }}/p/div /templatescript setup import { ref, reactive, toRefs } from vue;const message ref(Hello, Vue 3!); const state reactive({ count: 0 });const { count } toRefs(state); /script其它语法的使用 computed创建计算属性。watch观察响应式数据的变化并执行副作用。 templatedivpDouble Count: {{ doubleCount }}/pinput v-modelname placeholderName /p{{ name }}/p/div /templatescript setup import { ref, computed, watch } from vue;const count ref(2); const doubleCount computed(() count.value * 2);const name ref(Alice); watch(name, (newValue, oldValue) {console.log(Name changed from ${oldValue} to ${newValue}); }); /script引入组件的使用 !-- src/App.vue -- templateCounterComponent / /templatescript setup import CounterComponent from ./components/CounterComponent.vue; /script父组件传值的使用 defineProps 父传子 !-- src/components/ChildComponent.vue -- templatep{{ message }}/p /templatescript setup import { defineProps } from vue;const props defineProps({message: String }); /script!-- src/App.vue -- templateChildComponent messageHello, Child! / /templatescript setup import ChildComponent from ./components/ChildComponent.vue; /scriptdefineEmits 子传父 !-- src/components/ChildComponent.vue -- templatebutton clicksendMessageSend Message to Parent/button /templatescript setup import { defineEmits } from vue;const emit defineEmits([message]);const sendMessage () {emit(message, Hello from Child Component!); }; /script!-- src/App.vue -- templateChildComponent messagehandleMessage /p{{ parentMessage }}/p /templatescript setup import { ref } from vue; import ChildComponent from ./components/ChildComponent.vue;const parentMessage ref();const handleMessage (msg: string) {parentMessage.value msg; }; /script
http://www.w-s-a.com/news/159317/

相关文章:

  • 公司网站如何seo自己做资讯网站
  • 天津网站建设软件开发招聘企业信用信息查询公示系统上海
  • 网站备案中做正品的网站
  • 网站建设0基础学起青海企业网站开发定制
  • 网站定制项目上海快速建站
  • 大型视频网站建设方案东莞企业网站建设开发
  • 西安php网站制作可以用AI做网站上的图吗
  • 网站开发工程师和前端企业网络推广公司
  • 泉州开发网站的公司有哪些电脑网页翻译
  • 河北省建设机械会网站首页刚做的网站怎么收录
  • 什么网站专门做自由行的framework7做网站
  • 网页设计与网站建设书籍包头住房与城乡建设局网站
  • 重庆网站建设平台免费猎头公司收费收费标准和方式
  • 形象设计公司网站建设方案书打开一个不良网站提示创建成功
  • 网站手机页面如何做网站关键字 优帮云
  • 免费的黄冈网站有哪些下载软件系统软件主要包括网页制作软件
  • 企业微站系统重庆高端网站建设价格
  • 有没有做衣服的网站吗网站自适应开发
  • 青海省制作网站专业专业定制网吧桌椅
  • 网站开发的项目17岁高清免费观看完整版
  • 手机网站建设多少钱一个门网站源码
  • 重庆 网站开发天津住房和城乡建设厅官方网站
  • 泰安高级网站建设推广厦门高端网站建设定制
  • jsp网站开发引用文献手机seo排名
  • 创建一家网站如何创设计网页的快捷网站
  • 1688代加工官方网站h5开发教程
  • 静态网站源码下载网站怎么显示备案号
  • 网站代码设计网站开发维护任职要求
  • 长寿做网站的电话怎么快速刷排名
  • 上海市中学生典型事例网站邯郸全网推广