Thanks to visit codestin.com
Credit goes to github.com

Skip to content

从null或undefined变成[]的时候,不会被更新 #40

@z-ZYS-s

Description

@z-ZYS-s

Demo如下:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>
<body>

<script src="http://rawgit.com/sindresorhus/multiline/master/browser.js"></script>
<script src="http://rawgit.com/regularjs/regular/master/dist/regular.min.js"></script>
<script>
var ListView = Regular.extend({
  name: 'listView',
  config: function() {
    var self = this;
    setTimeout(function() {
      self.$update('list1', []);
      self.$update('list2', [{name: 1}]);
    }, 200);
  },
  template: multiline(function(){/*
    {#list list as item}
      <div>{item.name}</div>
    {/list}
  */})
});

var App = Regular.extend({
  config: function() {
    // this.data.children1 = undefined;
    // this.data.children2 = undefined;
  },
  template: multiline(function(){/*
    <listView list1={children1} list2={children2} />
    {#if children1}Length: {children1.length}{/if}
    {#if children2}Length: {children2.length}{/if}
  */})
});

(new App()).$inject('body');

</script>
</body>
</html>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions