相关疑难解决方法(0)

Polymer 1.0:如何从属性中将参数传递给Polymer函数?

有没有办法从其内部的元素属性传递参数到Polymer函数<template>

<script src="http://www.polymer-project.org/1.0/samples/components/webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="http://www.polymer-project.org/1.0/samples/components/polymer/polymer.html" />
<dom-module id="example-element">
  <template>
    ...
    <paper-button id="foo" on-tap="bar">Click</paper-button>
    ...
  </template>
</dom-module>
<script>
  (function() {
    Polymer({
      is: 'example-element',
      properties: {...},
      bar: function(arg){
        // Do stuff using argument arg
      }
    });
  })();
</script>
Run Code Online (Sandbox Code Playgroud)

背景研究

我已经梳理关于此事的沉默文件.它没有说你是否可以.但是当我尝试它时,它失败了.但也许我没有正确地做到这一点.所以我需要一些帮助.

我唯一遇到的是事件监听器,它似乎无法接受我想传递的参数.说,一个id或一个name.

以前的尝试

我尝试过(不成功)做的事情:

<paper-button id="foo" on-tap="bar('foo')"> Click </paper-button>
Run Code Online (Sandbox Code Playgroud)

但似乎没什么用.

事件监听器的想法不起作用,因为它们限制了参数,我无法得到,比方说,id我需要.

polymer polymer-1.0

38
推荐指数
3
解决办法
3万
查看次数

标签 统计

polymer ×1

polymer-1.0 ×1