Ember.js ArrayProxy uniq() 方法
Ember.js是一个基于Model-View-Controller(MVC)架构用于开发大型客户端Web应用的开源JavaScript框架。Ember.js是最广泛使用的前端应用框架之一。它旨在加快开发速度和提高生产力。目前,它被许多网站使用,包括Square,Discourse,Groupon,Linked In,Live Nation,Twitch和Chipotle。
uniq()方法用于获取唯一值的值数组。
语法:
参数: 它不接受任何参数。
返回值: EmberArray.
安装和运行Ember.js的步骤:
步骤1: 要运行下面的示例,您需要有一个Ember项目。首先需要安装ember-cli。在终端中输入以下代码:
步骤2: 现在你可以通过输入以下代码片段来创建项目:
启动服务器的方式如下:
示例1
键入以下代码以生成此示例的路径:
app/routes/uniq1.js
app/controllers/uniq1.js
app/templates/uniq1.hbs
输出: 访问 localhost:4200/uniq1 查看输出
示例2
键入以下代码生成路由
app/routes/uniq2.js
app/controllers/uniq2.js
app/templates/uniq2.hbs
输出: 访问 localhost:4200/uniq2 查看输出
参考链接: https://api.emberjs.com/ember/4.4/classes/ArrayProxy/methods/uniq?anchor=uniq