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

哪里有做微商网站元搜索引擎有哪些

哪里有做微商网站,元搜索引擎有哪些,平面设计的软件都有什么,酷家乐手机版1、自定义组件,并使用 v-model 进行数据双向绑定。 简述: 自定义组件使用 v-model 进行传参时,遵循 Vue 3 的 v-model 机制。在 Vue 3 中,v-model 默认使用了 modelValue 作为 prop 名称,以及 update:modelValue 作为…

1、自定义组件,并使用 v-model 进行数据双向绑定。

简述: 自定义组件使用 v-model 进行传参时,遵循 Vue 3 的 v-model 机制。在 Vue 3 中,v-model 默认使用了 modelValue 作为 prop 名称,以及 update:modelValue 作为事件名称。

例子:
首先,我们创建一个自定义组件 MyInput.vue,该组件使用 <script setup> 语法,并允许通过 v-model 绑定值:

<!-- MyInput.vue -->  
<template>  <input :value="modelValue" @input="updateValue" />  
</template>  <script setup>  
import { defineProps, defineEmits, ref } from 'vue';  const props = defineProps({  modelValue: String  
});  const emit = defineEmits(['update:modelValue']);  const updateValue = (event) => {  emit('update:modelValue', event.target.value);  
};  
</script>

在这个例子中,使用了 defineProps 来定义 modelValue prop,它对应于 v-model 绑定的值。同时,我们使用 defineEmits 来声明 update:modelValue 事件,该事件将在输入框的值变化时被触发。

接下来,在父组件中使用这个自定义组件,并通过 v-model 绑定一个数据属性:

<!-- ParentComponent.vue -->  
<template>  <div>  <p>Value in Parent: {{ inputValue }}</p>  <MyInput v-model="inputValue" />  </div>  
</template>  <script setup>  
import { ref } from 'vue';  
import MyInput from './MyInput.vue';  const inputValue = ref('');  
</script>

在父组件中,导入了自定义的 MyInput 组件,并使用 v-modelinputValue 绑定到该组件的 modelValue prop 上。当 MyInput 组件中的输入框值变化时,它会触发 update:modelValue 事件,进而更新父组件中的 inputValue

注意,在 <script setup> 中,不需要显式地返回任何东西给模板,因为所有的响应式状态(通过 refreactive 创建)和函数都会自动暴露给模板。这使得代码更加简洁和直观。

2、异步加载动态组件
  ├─ src              │  ├─ components              │  │  ├─ ChartA.vue         │  │  ├─ ChartB.vue        │  │  └─ ChartC.vue       │  └─ test-async.vue └─ package.json                       
异步加载组件

方式一:


<template><AsyncOne />
</template><script setup>
import { defineAsyncComponent } from "vue";const AsyncOne = defineAsyncComponent(() =>import("@/components/ChartA.vue")
);
</script>

方法二:vue3+vite5 中


<template><AsyncTwo/>
</template><script setup>
import { defineAsyncComponent, ref } from "vue";const AsyncTwo = ref(null);
AsyncTwo.value = registerComponent("/ChartC");// 使用异步组件的方式加载组件
const registerComponent = (componentPath) => {const modules = import.meta.glob("./components/**/*.{vue,tsx}");for (const item in modules) {if (item.includes(componentPath)) {return defineAsyncComponent(modules[item]);}}
};
</script>
异步加载动态组件
<template><div v-for="(item, index) in componentsInfo" :key="index"><component :is="item.loadComp" /></div>
</template><script setup>
import { defineAsyncComponent, onMounted, ref } from "vue";const componentsInfo = ref([{id: "1-1",title: "图表A",component: "/ChartA",},{id: "1-2",title: "图表B",component: "/ChartB",},{id: "1-3",title: "图表C",component: "/ChartC",},
]);onMounted(() => {processLoad(componentsInfo.value);
});const processLoad = (info) => {for (let i = 0; i < info.length; i++) {let item = info[i];if (!item.component) {continue;}let resComp = registerComponent(item.component);item.loadComp = resComp;}
};// 注册一个异步组件
const registerComponent = (componentPath) => {//获取 src/components 文件夹下所有组件const modules = import.meta.glob("./components/**/*.{vue,tsx}"); for (const item in modules) {if (item.includes(componentPath)) {return defineAsyncComponent(modules[item]);}}
};
</script>

效果:
在这里插入图片描述

3、
http://www.ds6.com.cn/news/29821.html

相关文章:

  • discuz门户论坛模板优化关键词排名推广
  • 天河做网站系统重庆网站快速排名优化
  • 迪奥官网网站做的好吗seo如何挖掘关键词
  • 网站建站哪个好网络营销和电子商务区别
  • 青海学会网站建设公司推广网站都有哪些
  • 在线直播网站怎么做cba最新积分榜
  • 专业的网站设计石家庄疫情最新情况
  • 苏州好的做网站的公司有哪些优化措施最新回应
  • 重庆特种作业操作证官网西安seo计费管理
  • 如何做资金盘网站seo 的作用和意义
  • 建网站容易吗百度知道网页版地址
  • 做微信的网站有哪些成都网站排名优化公司
  • 网站开发 思维导图网站链接推广工具
  • 宅男做网站营销软文小短文
  • 集团公司成立条件seo标题优化是什么意思
  • 做吃穿住行网站114黄页
  • wordpress开发企业网站最好用的搜索引擎
  • 桐乡住房和城乡规划建设局网站网址查询服务器地址
  • 网站设计的大公司优化大师下载安装app
  • 网站的开发语言如何在网上推广产品
  • 公司付的网站费怎么做分录全球十大搜索引擎入口
  • 网站建设公司固定ipseo搜索引擎优化工资薪酬
  • 东莞疫情什么时候开始的seo每日一帖
  • 成都疫情最新规定公告韩国seocaso
  • 免费建网站可以找哪家英文网站seo网络排名优化方法
  • 盐城做网站价格网络营销是以什么为基础
  • 将网站的字体设计成百分比的形式要怎样定义怎么宣传自己的产品
  • 安丘网站建设报价百度网站app
  • 自己做的电影网站打开很慢刷赞网站推广ks
  • 制作asp手机网站b2b网站推广优化