为此你可以安排
px-tile.html
类似:
DEMO
...
</style>
<div>Date : [[localDate]]</div>
...
date: {
type: Date,
observer:'_checkDate'
}
_checkDate(d) {
if (d) {
// you may set the options with this information: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString
var options = { year: 'numeric', month: 'long', day: 'numeric' };
this.set('localDate', d.toLocaleDateString('en-US', options))
}
}
保持父元素与上一个示例相同,但将属性名称更改为
date
这将是子元素的属性:
<template>
<px-tile
date=[[date]]>
</px-tile>
</template>