我创建了一个basicModalComponent,它负责处理基本操作,例如关闭、提交、显示页眉和页脚。将简单的消息放入我的模态正文中效果很好。
但我希望能够传递一个子组件来管理我的身体,如下所示:
this.modal = await this.modalController.create({
component: BasicModalComponent,
componentProps: {
title: `Share!`,
body: ChildContentViewComponent,
bodyProps: {... some data here},
// body: new ChildContentViewComponent({some data here}),
confirm: this.onConfirmDeleteAction,
cancelButton: true
}
});
Run Code Online (Sandbox Code Playgroud)
这将处理一些更复杂的逻辑。
现在,这就是身体在我的中显示的方式basicModalComponent
<p class="modal-body text-center scrollable scrollbar-hidden">
{{body}}
</p>
Run Code Online (Sandbox Code Playgroud)
显然,它与字符串文本配合得很好,但现在我想在这里放置一个子组件。
结果如下:
如果可能的话,在实例化期间使用来自父级的数据
但我不知道这是否可能或一个好的模式。我认为这是可能的,因为这就是modalController我实际上正在做的事情BasicModalComponent,但我仍然不确定这种模式。我研究过继承和组合,但也没有成功。
您有什么想法/建议吗?提前致谢。
我在手风琴中递归地调用组件以显示树状结构。
该代码适用于短输入,但在嵌套数据的递归调用上滞后
它就像一棵 json 树。
//sample.component.html
<app-tree [input]="data"></app-tree>
//tree.component.html
<mat-accordion>
<mat-expansion-panel hideToggle="true" (click)="toggleTree($event, input)">
<mat-expansion-panel-header>
<mat-panel-title>
<mat-icon>{{input.buttonName}}</mat-icon>
{{input.key}}
</mat-panel-title>
</mat-expansion-panel-header>
<ul class="main-obj"> // tried *ngIf here
<div class="obj-list" *ngFor="let item of input.value; trackBy: trackChanges">
<li>
{{item.key}}: {{item.value}}
</li>
<li style="list-style: none; margin-left: -40px;">
<app-tree [input]="item"></app-tree>
</li>
</div>
</ul>
</mat-expansion-panel>
</mat-accordion>
//tree.component.ts
import { Component, OnInit, Input, Output } from '@angular/core';
import { EventEmitter } from 'events';
@Component({
selector: 'app-tree',
templateUrl: './tree.component.html',
styleUrls: ['./tree.component.css']
})
export class TreeComponent implements OnInit { …Run Code Online (Sandbox Code Playgroud) 我希望您在另一个隔离日表现出色!
我正在尝试使用 i18n 更改 React 应用程序的语言,但遇到问题。
这是我正在使用的代码片段(此代码位于组件 TopBar.jsx 中)
function onSelectFlag(countryCode) {
switch (countryCode) {
case "US": {
i18n.changeLanguage("en");
break;
}
case "BR": {
i18n.changeLanguage("po");
break;
}
default: {
i18n.changeLanguage("es");
break;
}
}
}Run Code Online (Sandbox Code Playgroud)
问题是,这段代码仅更改组件语言,而不更改整个应用程序语言。我做了一些研究,但没有发现任何东西......
有人知道如何解决这个问题吗?
谢谢!
我在 Angular-9 应用程序中有 3 个组件,如下所示:
组件1
<div>
// I have a button here with Click Event.
</div>
Run Code Online (Sandbox Code Playgroud)
组件2
<div>
// I have a Grid here.
</div>
In a class file I'm getting Data and Binding Grid using ngOnInit() method.
Run Code Online (Sandbox Code Playgroud)
我在第三个组件中使用这两个组件,如下所示:
组件 3
<div id='third-component'>
<component-one></component-one>
<component-two></component-two>
</div>
Run Code Online (Sandbox Code Playgroud)
我想通过单击Component1中的按钮刷新Component2数据。这个怎么做?
admin-bro 的登录页面显示“欢迎!”。我需要将其更改为其他内容。AdminBro 中可以吗?
PS:我使用的是AdminBro v1.6.6版本。PPS:我已经尝试过这个和相应的链接。这对我不起作用。是因为我的版本问题吗?提前致谢!
我有一个下一个项目,在这里存储: https: //github.com/DoctorSte/remoteOS
我有一个 Columns 组件,它有一个名为 grid-cols-[x] 的类,其中 X 是一个 prop。
export const Columns = ({
children,
columns,
border,
background,
align,
...rest
}) => {
return (
<section
className={`grid md:grid-cols-${columns} grid-cols-1 items-${align} border-t-${border} ${background} gap-4 px-10 py-10 lg:px-48 w-full `}
{...rest}
>
{children}
</section>
);
};
Run Code Online (Sandbox Code Playgroud)
在本地它显示正常,但在生产中柱结构会制动。经检查,该部分将“grid-cols-4”作为一个类,但显示为单列。知道可能是什么原因造成的吗?
我正在使用 VuePress 版本:
"devDependencies": {
"vuepress": "^2.0.0-beta.26"
}
Run Code Online (Sandbox Code Playgroud)
我无法将简单的 .vue 组件添加到我的 .md 页面。
我的 Github链接
在这里尝试了其他解决方案,但似乎没有任何帮助: 解决方案1 解决方案2
我正在遵循VuePress官方文档中有关组件的指南。但我得到的只是一个零大小的组件(没有显示内容)
非常感谢任何解决方案。
编辑:
让它比检查我的 github 更简单一些。整个项目无论如何只包含 2 个文件。
所以我所做的是在 .vuepress/components 中创建一个新的 component.vue 文件:
<template>
<h1>Hello from my test component</h1>
</template>
<script>
export default {}
</script>
<style></style>
Run Code Online (Sandbox Code Playgroud)
并尝试将其添加到我的 README.md 文件中:
# Hello VuePress
### test component
<TestComponent />
<kebab-case-test-component />
Run Code Online (Sandbox Code Playgroud)
我的文件夹树的屏幕截图:
您好,我正在尝试在 Vue 3 中导入一个组件。这是我的组件结构:
+src
+App.vue
+components
+Navbar.vueRun Code Online (Sandbox Code Playgroud)
在我的 App.vue 中我尝试过:
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<template>
<div>
<Navbar/>
</div>
</template>
<script>
import Navbar from './components/Navbar.vue';
</script>Run Code Online (Sandbox Code Playgroud)
import { createApp } from 'vue'
import router from './router'
import mitt from 'mitt';
const emitter = mitt();
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue-3/dist/bootstrap-vue-3.css'
import BootstrapVue3 from 'bootstrap-vue-3'
import App from './App.vue'
const app = createApp(App)
app.use(router)
app.use(BootstrapVue3)
app.mount('#app')
app.config.globalProperties.emitter = emitter;Run Code Online (Sandbox Code Playgroud)
但我收到这个错误:
Already included file name '/home/jip/Projects/snippedit/client/src/components/Navbar.vue' differs from file name '/home/jip/Projects/snippedit/client/src/components/navBar.vue' only in …Run Code Online (Sandbox Code Playgroud)我想在某些页面中隐藏页脚组件
<div className="App">
<Header setShowMenu={setShowMenu} />
{showMenu ? <Menu navigateTo={navigateTo} setShowMenu={setShowMenu} /> : null}
<Main navigateTo={navigateTo} />
<Footer navigateTo={navigateTo} />
</div>
Run Code Online (Sandbox Code Playgroud)
<div>
<Routes>
<Route path="/" element={<HomePage navigateTo={navigateTo} />} />
<Route path="/precard" element={<PreCard />} />
<Route path="/order" element={<Order />} />
<Route path="/contact" element={<Contact />} />
<Route path="/thankspage" element={<ThanksPage navigateTo={navigateTo}/>} />
<Route path="/*" element={<HomePage />} />
</Routes>
</div>
Run Code Online (Sandbox Code Playgroud)
注意:index.js 中的 Router
所以我想隐藏./order页面中的页脚
我希望你们能为我找到解决方案:)
components ×10
angular ×3
reactjs ×3
javascript ×2
vue.js ×2
admin ×1
admin-bro ×1
angular8 ×1
i18next ×1
import ×1
next.js ×1
node.js ×1
parent-child ×1
react-hooks ×1
react-native ×1
react-router ×1
recursion ×1
tailwind-css ×1
tree ×1
typescript ×1
vuejs3 ×1
vuepress ×1