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

企业做网站排名备案查询平台官网

企业做网站排名,备案查询平台官网,wordpress时间调用,网站推广网站使用场景: 多个组件通过component标签挂载在同一个组件中,通过触发时间进行动态切换。vue3与vue2用法不一样,这里有坑! 使用方法: 1.通过vue的defineAsyncComponent实现挂载组件 2.component中的is属性 父组件&am…

使用场景:

多个组件通过component标签挂载在同一个组件中,通过触发时间进行动态切换。vue3与vue2用法不一样,这里有坑!

使用方法:

1.通过vue的defineAsyncComponent实现挂载组件

2.component中的is属性

父组件:

<template><div><div v-for="item in person.data" :key="item" @click="btn(item)">{{ item.name }}</div><h1>下面为动态组件</h1><component :is="person.componen"> </component></div>
</template><script setup>
import { reactive, onMounted, defineAsyncComponent } from "vue";
const One = defineAsyncComponent(() => import("./One.vue"));
const Two = defineAsyncComponent(() => import("./Two.vue"));const person = reactive({componen: "",data: [{ type: "one", name: "显示组件一" },{ type: "two", name: "显示组件二" },],
});
function btn(item) {if (item.type == "one") person.componen = One;if (item.type == "two") person.componen = Two;
}onMounted(() => {});
</script>

子组件:

<template><div>组件一</div><el-input v-model="person.input"></el-input>
</template><script setup>
import { ref, reactive, onMounted, computed, watch } from "vue";const person = reactive({ input: "" });
onMounted(() => {console.log("组件一");
});
</script>
<style scoped lang='less'>
</style>

效果:

这里会有警告:Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with `markRaw` or using `shallowRef` instead of `ref`. (Vue收到一个组件,该组件被设置为反应对象。这可能会导致不必要的性能开销,应该通过用“markRaw”标记组件或使用“shallowRef”而不是“ref”来避免。)

        

解决方法:

1.使用shallowRef替换响应式

<template><div><div v-for="item in person.data" :key="item" @click="btn(item)">{{ item.name }}</div><h1>下面为动态组件</h1><keep-alive><component :is="componen"> </component></keep-alive></div>
</template><script setup>
import { reactive, onMounted, defineAsyncComponent, shallowRef } from "vue";
let componen = shallowRef(null);
const Two = defineAsyncComponent(() => import("./Two.vue"));
const One = defineAsyncComponent(() => import("./One.vue"));
let obj = shallowRef({Two,One,
});
const person = reactive({data: [{ type: "one", name: "显示组件一" },{ type: "two", name: "显示组件二" },],
});
function btn(item) {if (item.type == "one") componen.value = obj.value.One;if (item.type == "two") componen.value = obj.value.Two;
}onMounted(() => {});
</script>
<style scoped lang='less'>
</style>

http://www.tj-hxxt.cn/news/29422.html

相关文章:

  • 上海网站建设网页制知乎软文推广
  • 做网站私活多少钱宁波谷歌seo
  • 西方设计网站sem和seo区别与联系
  • 展示形网站怎么建株洲seo
  • 十大免费开发平台app杭州网站优化平台
  • 信主网站搜索引擎排名大全
  • 滕州手机网站建设叶涛网站推广优化
  • 做网站一般是什么工作成人职业技术培训学校
  • 网站备案信息变更关键词挖掘工具站
  • 上海室内软装设计公司排名seo测试
  • 优秀个人网站windows优化大师自动安装
  • 湛江专业做网站seo软件
  • 管理咨询公司的运作模式seo五大经验分享
  • 网站规划名词解释百度公司招聘官网
  • 东莞米可网络怎么样苏州首页排名关键词优化
  • 做网站公司运营部百度小说排行榜总榜
  • 做企业公示的数字证书网站推广普通话宣传标语
  • 怎么做电影流量网站吗软文推广营销
  • 邯郸景区网站制作一键免费创建论坛网站
  • 深圳响应式网站开发成都seo优化公司排名
  • 公司网站域名如何续费百度数据中心
  • 政协系统网站建设百度手机快速排名点击软件
  • 高端企业网站建设自己如何注册一个网站
  • 网站制作要用哪些软件有哪些海外独立站
  • 奉节做网站公司培训课程有哪些
  • 网站如何快速收录专门做网站的公司
  • 网站空间和域名绑定线上营销活动主要有哪些
  • 网站建设询价山东网站seo
  • 网站建设的买外链有用吗
  • phpcms移动端网站怎么做seo专业术语