数字值正在改变,有人知道发生了什么事吗?

Number value is being changed, anyone know what's going on?

所以我正在学习 Ember.js 并且我正在尝试显示一个数字值 (fips) 但由于某种原因它将值更改为另一个数字。我认为正在发生的事情是 ember 出于某种原因自动将数字转换为其他数字,但不确定原因。如果有人能帮我解决这个问题,我将不胜感激。提前致谢!

Javascript:

App = Ember.Application.create();

App.Router.map(function() {
  this.resource('liens', function(){});
  this.resource('portfolio', function(){});
});

App.IndexRoute = Ember.Route.extend({
  model: function(){
    return App.Liens;
  }
});

App.Liens=[
  {
          id: 1,
          apn: 'apn1',
          fips: 01700,
          state: 'CA',
          county: 'Los Angeles',
          address: 'somewhere st123',     
  },
  {
          id: 2,
          apn: 'apn2',
          fips: 01744,
          state: 'FL',
          county: 'Miami',
          address: 'someplace st700',     
  },
  {
          id: 3,
          apn: 'apn3',
          fips: 05690,
          state: 'FL',
          county: 'Orlando',
          address: 'ExactPlace in st111',   
  }
];

App.Liens = Ember.Model.extend({
  id: DS.attr('number'),
  apn: DS.attr('string'),
  fips: DS.attr('number'),
  state: DS.attr('string'),
  county: DS.attr('string'),
  address: DS.attr('string')
});

HTML:

<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
  <meta charset="utf-8">
  <title>Ember Starter Kit</title>
  <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.1/normalize.css">
    <script src="http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v2.0.0.js"></script>
  <script src="http://builds.emberjs.com/tags/v1.9.1/ember.js"></script>
</head>
<body>

  <script type="text/x-handlebars">
    <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container-fluid">
          <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
              <span class="sr-only">Toggle navigation</span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
            {{#link-to 'index' tagName='a' classNames='navbar-brand'}}Project name{{/link-to}}
          </div>
          <div id="navbar" class="navbar-collapse collapse">
            <ul class="nav navbar-nav navbar-right">
              <li>{{#link-to 'portfolio' tagName='a'}}Portfolio{{/link-to}}</li>
              <li><a href="">Settings</a></li>
              <li><a href="">Profile</a></li>
              <li><a href="">Help</a></li>
            </ul>
            <form class="navbar-form navbar-right">
              <input type="text" class="form-control" placeholder="Search...">
            </form>
          </div>
        </div>
      </nav>



      <div class="container">
      {{outlet}}
      </div>
  </script>

  <script type="text/x-handlebars" data-template-name="index">

    <h2 class="sub-header" >Liens</h2>
      <div class="table-responsive">
        <table class="table table-striped">
          <thead>
            <tr>
              <th>id</th>
              <th>apn</th>
              <th>fips code</th>
              <th>State</th>
              <th>County</th>
              <th>Address</th>
            </tr>
          <tbody>
          {{#each lien in model}}
            <tr>
              <td>{{lien.id}}</td>
              <td>{{lien.apn}}</td>
              <td>{{lien.fips}}</td>
              <td>{{lien.state}}</td>
              <td>{{lien.county}}</td>
              <td>{{lien.address}}</td>
            </tr>
          {{/each}}
          </thead>
  </script>

</body>
</html>

我试过像这样添加控制器:

App.IndexController = Ember.Controller.extend({
  fipsCode: Ember.computed.alias('fips')
});

我在 html 中将其更改为 lien.fipsCode,但它什么都不显示

将您的数字类型更改为字符串,因为您要显示的实际上不是数值,而是仅包含数字字符的字符串。

编辑

事实上,在 javascript 中,以 0 开头的数字是八进制数的前缀 :) 这就是为什么你会得到更奇怪的值 source