사용자가 제공하지 않을 때 기본값을 사용하는 사용자 지정 요소에 옵션 개체 특성을 설정하려고합니다. 내가 지금 그 옵션 값과 기본 값 전달에게 설정을 설정하는 방법 위의 코드는 항상 내가에서 통과하려고보다 우선 요소 생성자에 지정된 값으로 작동하지 않습니다기본값이있는 폴리머 개체 특성
<!DOCTYPE html>
<html>
<head>
<script src="bower_components/platform/platform.js"></script>
<link rel="import" href="bower_components/polymer/polymer.html">
</head>
<body>
<my-element options="{{{
option_1: 'val1',
option_2: 'val2',
allow_this: true,
allow_that: false
}}}">
</my-element>
</body>
</html>
<polymer-element name="my-element" attributes="options">
<template>
<ul>
<!-- ... -->
</ul>
</template>
<script>
Polymer('my-element', {
options: {
option_1: 'default_val1',
option_2: 'default_val2',
allow_this: false,
allow_that: false
}
});
</script>
</polymer-element>
. 대체 수단으로 만 사용됩니까?
'bindings'을 값'options = '{ "option_1": "[[ajax.response]]"}'로 전달하는 것은 어떻습니까? Polymer는 구성 요소에서 초기화 할 경우 다음과 같이 변환하지 않습니다 :'options : {}' –