Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/396.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为什么我的路由在Ember Js中不起作用?_Javascript_Ember.js - Fatal编程技术网

Javascript 为什么我的路由在Ember Js中不起作用?

Javascript 为什么我的路由在Ember Js中不起作用?,javascript,ember.js,Javascript,Ember.js,我正在使用rails API和前端作为Ember开发todoApp。 我遵循了这个教程 然而,它有点旧,我有点迷失在我的路线 我有一个todos.hbs,应该呈现为localhost:4200/,但它是一个清晰的页面 下面是我的router.js的外观: import EmberRouter from '@ember/routing/router'; import config from './config/environment'; const Router = EmberRouter.ex

我正在使用rails API和前端作为Ember开发todoApp。 我遵循了这个教程 然而,它有点旧,我有点迷失在我的路线

我有一个todos.hbs,应该呈现为localhost:4200/,但它是一个清晰的页面

下面是我的router.js的外观:

import EmberRouter from '@ember/routing/router';
import config from './config/environment';

const Router = EmberRouter.extend({
  location: config.locationType,
  rootURL: config.rootURL
});

Router.map(function() {
  this.route('todos', { path: '/' });
});

export default Router;
和我的路线/todos.js:

在我的application.hbs上,只有一个“{outlet}”

我的todos.hbs是这样的:

<section id="todoapp">
  <header id="header">
    <h1>todos</h1>
  {{input type="text" id="new-todo" placeholder="What needs to be done?" value=newTitle action="createTodo"}}
  </header>

  <section id="main">
  <ul id="todo-list">
  {{#each itemController="todo"}}
    <li {{bind-attr class="isCompleted:completed isEditing:editing"}}>
    {{#if isEditing}}
      {{input insert-newline=(action "acceptChanges")}}
    {{else}}
        {{input type="checkbox" checked=isCompleted class="toggle"}}
        <label {{action "editTodo" on="doubleClick"}}>{{title}}</label>
      <button {{action "removeTodo"}} class="destroy"></button>
    {{/if}}
    </li>
  {{/each}}
  </ul>

    <input type="checkbox" id="toggle-all">
  </section>
</section>

<footer id="info">
  <p>Double-click to edit a todo</p>
</footer>
{{outlet}}

我注意到您的routes/todos.js调用了这个.store.find'todo';。已删除使用store.findtype。我想你得给这个打电话。商店。findAll'todo'

我注意到您的routes/todos.js调用了这个.store.find'todo';。已删除使用store.findtype。我想你得给这个打电话。商店。findAll'todo'

正如Joe已经提到的,store.find'todo已经被删除,从我所看到的来看,它在2015年被删除了,但我不能100%确定这一点正如Joe已经提到的,store.find'todo已经被删除,从我所看到的来看,它在2015年被删除了,但我不能100%确定您是否特别面临任何控制台错误,无法识别的错误?我知道。首先,我必须在我的路由器中将this.resource更改为this.routein。现在,我有一个无法读取未定义类型错误的属性“extend”:无法读取未定义错误的属性“extend”。您使用的是什么版本的ember?{{bind attr}}在2.0中被删除,您正在使用新模块importHi@PatsyIssa,我目前正在使用3.4.2。是的,确实,本教程有点过时。@PatsyIssa当然,我提到了非官方指南或教程。您是否面临任何控制台错误,尤其是无法识别的错误?我会。首先,我必须在我的路由器中将this.resource更改为this.routein。现在,我有一个无法读取未定义类型错误的属性“extend”:无法读取未定义错误的属性“extend”。您使用的是什么版本的ember?{{bind attr}}在2.0中被删除,您正在使用新模块importHi@PatsyIssa,我目前正在使用3.4.2。是的,确实,本教程有点过时。@PatsyIssa当然,我提到了非官方指南或教程。
<section id="todoapp">
  <header id="header">
    <h1>todos</h1>
  {{input type="text" id="new-todo" placeholder="What needs to be done?" value=newTitle action="createTodo"}}
  </header>

  <section id="main">
  <ul id="todo-list">
  {{#each itemController="todo"}}
    <li {{bind-attr class="isCompleted:completed isEditing:editing"}}>
    {{#if isEditing}}
      {{input insert-newline=(action "acceptChanges")}}
    {{else}}
        {{input type="checkbox" checked=isCompleted class="toggle"}}
        <label {{action "editTodo" on="doubleClick"}}>{{title}}</label>
      <button {{action "removeTodo"}} class="destroy"></button>
    {{/if}}
    </li>
  {{/each}}
  </ul>

    <input type="checkbox" id="toggle-all">
  </section>
</section>

<footer id="info">
  <p>Double-click to edit a todo</p>
</footer>
{{outlet}}
import DS from 'ember-data';

export default DS.RESTAdapter.extend({
  host: 'http://localhost:3000/api'
});