问题标签 [vue-dynamic-components]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
vue.js - 使用在Vue中标记为第一个孩子 tag in Vue 2
In Vue,js 2, I would like to use this pattern:
<template>
<component :is="tagType">
...
</component>
</template>
Where tagT
In Vue,js 2, I would like to use this pattern:
Where tagType is a generic computed property as follow:
Is this a valid approach? Would you suggest any other pattern to achieve the same result?
You can use Apps Script for this. Use a time-driven installable trigger in a script that protects/locks the sheet.
Your code should be something like this:
In Vue,js 2, I would like to use this pattern:
<template>
<component :is="tagType">
...
</component>
</template>
Where tagT
In Vue,js 2, I would like to use this pattern:
Where tagType is a generic computed property as follow:
Is this a valid approach? Would you suggest any other pattern to achieve the same result?
You can use Apps Script for this. Use a time-driven installable trigger in a script that protects/locks the sheet.
Your code should be something like this:
javascript - 如何在Vue中为嵌套递归树结构放置备用背景
我正在尝试构建具有嵌套树结构的 OKR 类型的组件。我使用了动态递归组件来不制作深度硬代码。树的所有节点都可以展开。但是我无法编写适当的逻辑来使节点具有备用背景。由于节点可以扩展,因此子节点的背景必须相应调整。
这是我在代码沙箱中的示例:此处的代码链接。
展开时,它应该像这样调整子节点背景:
vuex - vue3 多语言站点,计算属性的可能副作用,动态组件,
我在 vuex + vue-router + 动态组件的帮助下显示网站的页眉和页脚。我通过 vuex 从 vue-router 获取当前路由并将数据“注入”到 App.vue 中,其中有我的页眉和页脚。我可以控制台记录每个页面的正确路线。
app.vue 标记如下所示:
现在我使用计算属性 selectedFooter 和 selectedHeader 来显示正确的组件:
它基本上可以工作,但我认为我已经遇到了副作用,因为我没有正确使用计算属性,例如,一条路线显示到错误的语言标题,即使来自商店的路线数据绝对正确?
我想使用观察者会更好,但是如何?
vue.js - Vue JS:在启动组件后添加模板所需的数据
我创建了一个使用 mustache 语法 ({{ obj.name }}) 的模板,但我没有数据来填写该语法。
创建组件并在一段时间后发出 API 请求后,我将获得要更新到组件数据的信息(vm._data[obj] = {name: 'test'})。
在这种情况下,由于我的数据不容易用于填充模板(在启动 vue 组件时),因此即使在我获取和更新数据之后,我的模板也永远不会更新。
javascript - 在 Vue 中使用带有 props 的动态组件的优雅方式
以下案例:我有一个 API 输出我的页面的所有内容,以及它的结构等(为了更好地理解,成像一个包含页面构建器的 CMS,作者可以通过拖放将组件放置到生成页面内容,由该api传递到前端)。
api 输出的结构类似于:
因此,要生成相关内容,我会考虑使用动态组件,例如:
但是,这样做我会面临一个问题,即我必须以某种方式将属性数据添加到我的组件中,这(据我所知)在 Vue 文档中没有描述。所以现在我想知道如何将道具传递给具有完全不同道具的动态组件(英雄可能有一个图像,表单可能有输入占位符等等) - 任何想法?
vue.js - 如何在 vueJS 中创建动态组件
我是 vueJS 的新手,正在尝试动态加载组件。我在网上搜索并尝试了许多建议,但仍然无法让它发挥作用。
场景:我想要一个“shell”组件,它充当容器,用于根据用户的选择换入和换出其他组件。这些组件的文件名将从数据库中提供
这是外壳组件:
这不起作用。
如果我对组件文件名进行硬编码,它可以正常工作......例如
return ()=> import('MyComponent.vue');
当我将导入语句更改为使用变量时,即使该变量包含与我硬编码的相同字符串,它也会出错。
我究竟做错了什么?