简体   繁体   English

如何为余烬引擎定义路线

[英]How to define a route for ember-engine

As the title said, I can't figure out how to define a route for an Ember.js Engines in an Ember.js Application. 如标题所述,我不知道如何在Ember.js应用程序中为Ember.js 引擎定义路由。
I tried to follow the tutorial, but I don't understand how the route work. 我尝试按照本教程进行操作,但是我不了解该路线的工作方式。
An add-on made with ember-engines cannot be placed in the Application, so where should he be placed? 用ember引擎制作的附加组件无法放置在应用程序中,那么他应该放置在哪里? In another repository, I suppose, but then how to define its route in the app/router.js . 我想在另一个存储库中,然后在app / router.js中定义其路由。

I will recap everything I have done until now: 我将回顾一下到目前为止我所做的一切:

  1. Created the addon : 创建了插件:
    ember addon myAddon
  2. Installed the addon ember-engines in both repositories (application and addon): 在两个存储库(应用程序和插件)中安装了插件余烬引擎:
    ember install ember-engines

Right now, I have two repositories, but the addon one is quite empty. 现在,我有两个存储库,但是附加存储库之一是空的。 So we will add in this repository all the things that are needed for the addon to "work." 因此,我们将在此存储库中添加插件“工作”所需的所有东西。

  1. Added my environment variable, my index.js , my addon/route.js and my engine.js . 添加了我的环境变量, index.jsaddon / route.jsengine.js

  2. I putted <h3>Hello World!</h3> in my addon/templates/application.hbs . 我将<h3>Hello World!</h3>放在了我的addon / templates / application.hbs中

And here comes the problematic part. 这是有问题的部分。 How do I call the addon in my application? 如何在应用程序中调用插件? I mean in the router.js of my application? 我的意思是在我的应用程序的router.js中?

  1. I tried: 我试过了:
    this.mount('myAddon'); this.mount('myAddon', { path: '../../addon/myAddon}); which is the path to my addon, but I can of understand this is not a good way to call it. 这是我的插件的路径,但是我可以理解,这不是调用它的好方法。

So if any of you can help me out, that will be very appreciated. 因此,如果有任何人可以帮助我,将不胜感激。

I solved it. 我解决了 The problem was not in the addon itself, but in the package.json of my app. 问题不在于插件本身,而在于我应用程序的package.json。 I just added in the dependencies "myAddon": "path/to/my/addon" . 我刚刚添加了dependencies "myAddon": "path/to/my/addon"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM