gpt4 book ai didi

ember.js - Ember 自定义组件的 id 属性

转载 作者:行者123 更新时间:2023-12-04 01:34:49 24 4
gpt4 key购买 nike

嗨,有没有一种方法可以自定义组件的 id(我知道它可以用于 View ......但 View 自 ember 1.13 以来已被弃用):

例如。以下内容适用于该 View :

export default Ember.View.extend({
classNames: ['music-js', 'vjs-default-skin', 'center-x','center-block'],
attributeBindings: ['id'],
id: 'musicOne',

但是,当我尝试对组件使用 id 绑定(bind)时,控制台日志中出现异常:
export default Ember.Component.extend({
classNames: ['music-js', 'vjs-default-skin', 'center-x','center-block'],
attributeBindings: ['id'],
id: 'musicOne',

未捕获的类型错误:提供的元素或 ID 无效。

最佳答案

2种方式:

在组件本身中:

export default Ember.Component.extend({
elementId: 'the-id'
});

或者在组件调用本身中指定它:
{{my-component id="the-id"}}

关于ember.js - Ember 自定义组件的 id 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31363967/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com