繁体   English   中英

PolymerJS简单的数据绑定。 如何在屏幕上输出属性?

[英]PolymerJS simple databinding. How to output properties on screen?

我想输出保存在属性中的值。

柱塞链接

这是一个简单的demo-element.html 我只想显示标题。

但是{{title}}{{this.title}}

<dom-module id="demo-element">
    <template>
        <style>
            :host {
                display: block;
            }
        </style>

        <h1>'title' in properties not showing</h1>
        <h2>{{this.title}}</h2>

    </template>
    <script>
        Polymer({
            is: 'demo-element',

            properties: {
                title: 'This is a regular Demo Title'
            }
        });
    </script>
</dom-module>

如何在屏幕上输出我的属性?

我正在搜索相当于vue{{ $data | json }} {{ $data | json }}

再次链接

数据绑定时暗含了this一点。 所以这

<h2>{{this.title}}</h2>

变成这个

<h2>{{title}}</h2>

一种可能的解决方案是将value属性分配给我的title属性,如下所示:

<dom-module id="demo-element">
<template>

    <h1>'title' in properties not showing</h1>
    <h2>{{this.title}}</h2>

</template>
<script>
    Polymer({
        is: 'demo-element',

        properties: {
            title: {
                 type: String,
                 value: 'This is a regular Demo Title'
            }
        }
    });
</script>

然后输出仅引用标题的值,而不使用this ,如下所示:

<h2>{{ Title }}</h2>

这是工作中的柱塞:

柱塞链接

我仍然想知道vue的{{ $data | json }} {{ $data | json }}方法?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM