[英]Barrel in Vuejs
可以在 Vuejs 中做一個桶嗎?
如果是,請舉個例子,我在 web 中搜索,但我沒有找到任何東西
喜歡js
// app/domain/index.js
export * from './negotiation';
export * from './negotiations';
// app/app.js
import { Negotiation, Negotiations } from './domain';
當我使用 bucket.vue 文件時,我會這樣做:
創建桶
//index.js
import File1 from './file1'
import File1 from './file1'
export {
File1,
File2
}
使用桶文件
import { File1, File2 } from './path'
可能這會起作用:
// app/domain/index.js
import NegotiationModule from './negotiation';
import NegotiationsModule from './negotiations';
export const Negotiation = NegotiationModule;
export const Negotiations = NegotiationsModule;
// app/app.js
import { Negotiation, Negotiations } from './domain';
(我沒有測試過,所以它不能工作)
你可以做
export {default as MyModule} from './MyModule.vue';
在與組件相同的文件夾中創建 index.js 文件(協商、協商)
應用程序/域/index.js
import negotiation from './negotiation.vue'
import negotiations from './negotiations.vue'
export default { negotiation, negotiations };
應用程序/app.js
import domains from './domain';
const { negotiation, negotiations } = domains;
export default {
components: { negotiation, negotiations }
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.