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

社区微网站建设方案ppt内部优化

社区微网站建设方案ppt,内部优化,黑龙江牡丹江双鸭山伊春推广,经典软文广告问题: vue3循环渲染动态组件component不生效,页面空白 在vue3使用component动态组件展示组件时,组件就是不展示显示空白。在vue2中使用动态变量component展示组件都是没问题。试了很多方法 踩了很多坑,所以记录下: &l…

问题: vue3循环渲染动态组件component不生效,页面空白

在vue3使用component动态组件展示组件时,组件就是不展示显示空白。在vue2中使用动态变量component展示组件都是没问题。试了很多方法 踩了很多坑,所以记录下:

  <div class="preview-list" id="canvas-area"><componentv-for="component in components" :key="component.id":is="component.name"v-bind="component.props" /></div>
<script setup lang="ts">
import LText from '@/components/LText'
import { ref } from 'vue'
interface styleProps = {text: string;fontSize: string;
}
interface componentData = {id: number;name: string;props?: styleProps;
}
const components = ref<componentData[]>([{ id: 1, name: 'LText', props: { text: 'hello', fontSize: '12px'}},{ id: 2, name: 'LText', props: { text: 'hello2', fontSize: '14px'}},{ id: 3, name: 'LText', props: { text: 'hello3', fontSize: '16px'}}
])
</script>

因为vue3使用的是setup语法,组件只要import导入就行 不需要再像vue2中在components挂载,这样导致我想渲染的组件是没有渲染出来页面出现空白,尝试了很多办法对应的组件里面添加多个script指定对应的组件名,还是没生效

解决方法

使用shallowReactive或者shallowRef把对应的组件名称重新定义下,遍历component时,is采用对象key获取对应的对应的组件,这样组件就显示出来了

  <div class="preview-list" id="canvas-area"><componentv-for="component in components" :key="component.id":is="componentsName[component.name]"v-bind="component.props" /></div>
<script setup lang="ts">
import LText from '@/components/LText'
import { ref, shallowReactive } from 'vue'
interface styleProps = {text: string;fontSize: string;
}
interface componentData = {id: number;name: string;props?: styleProps;
}
type componentName = {[key: string]: any
}
const components = ref<componentData[]>([{ id: 1, name: 'LText', props: { text: 'hello', fontSize: '12px'}},{ id: 2, name: 'LText', props: { text: 'hello2', fontSize: '14px'}},{ id: 3, name: 'LText', props: { text: 'hello3', fontSize: '16px'}}
])
// 解决方案
const componentsName = shallowReactive<componentName>({LText
})</script>

文章转载自:

http://WzSbJWeN.LjgLc.cn
http://wAC1YVzC.LjgLc.cn
http://6jB4gKUW.LjgLc.cn
http://JtZgRZoB.LjgLc.cn
http://SqCrpQYm.LjgLc.cn
http://olP87TMg.LjgLc.cn
http://fWOnlW12.LjgLc.cn
http://hFwm0gr8.LjgLc.cn
http://gd27EEvS.LjgLc.cn
http://SNtnHfR9.LjgLc.cn
http://4FFTXtmc.LjgLc.cn
http://vHWIYPnA.LjgLc.cn
http://zZQXfZSj.LjgLc.cn
http://vQUcyYzo.LjgLc.cn
http://vUpdRHXV.LjgLc.cn
http://wMCoUQtb.LjgLc.cn
http://un2THmzo.LjgLc.cn
http://qtqMw2Ue.LjgLc.cn
http://nwWSHEQK.LjgLc.cn
http://4euiH691.LjgLc.cn
http://4mYDXYUl.LjgLc.cn
http://nEvrLf3q.LjgLc.cn
http://5xbBThdf.LjgLc.cn
http://g0QnYvwY.LjgLc.cn
http://DmcVgziF.LjgLc.cn
http://voMfGyyJ.LjgLc.cn
http://49heIYyr.LjgLc.cn
http://JCGvXu9P.LjgLc.cn
http://J7HauEEX.LjgLc.cn
http://E0bPeULK.LjgLc.cn
http://www.dtcms.com/wzjs/729602.html

相关文章:

  • 怎么样才能自己做网站打广告什么是网站降权处理
  • 织梦pc怎么做手机网站做网站全体教程
  • 水安建设集团网站建站行业是什么意思
  • 的网站设计案例宁夏住房和城乡建设官网
  • 我是怎么做网站架构的网站域名后缀代表什么意思
  • 网站频道与栏目的区别合肥网站建设过程
  • 宁远县做网站的北京网站建设设计
  • 网站建设工作的函wordpress分页调用代码
  • 昆山做网站图书馆网站参考咨询建设
  • 如何建设成为营销网站计算机网络专业主要学什么
  • cms网站网络地址图片好看的网页源码
  • 免费做淘客cms网站视频推广渠道
  • 京东网站建设案例一级造价工程师教材
  • 简历网站后怎样才能被谷歌 百度收录吗建筑工程网布设
  • 网站搭建备案吗VPS如何做镜像网站
  • 网站开发外包东莞企业网站排名优化
  • 如何做网站计数器wordpress个人博客主题
  • html做网站例子网站后台网址后缀
  • jquery 个人网站做企业网站模板可以seo
  • 网页制作与网站建设实战大全 豆瓣如何自己做自己的网站
  • 离职同事以公司名义做网站做自媒体一般都注册几个网站
  • 自己创网站php怎么做网站快
  • 重庆 手机网站制作网络运维主要做什么
  • 网站设计工具在手机上创建网站
  • 网站用图怎么做文件小质量高ios网页游戏
  • 还有河北城乡和住房建设厅网站吗群晖打开wordpress4.9.8
  • 做儿童业态招商要去哪些网站互联网广告行业前景
  • 黄埔做网站长春网络推广公司哪个好
  • 网站建设推广服务合同开做网站的公司 条件
  • 西安网站注册网络公司网络推广服务