this
创建元素并调用其方法的示例。我在做:
class streetViewCard extends Polymer.Element {
static get is() {
return 'street-view-card';
}
...
updateLocation(coordinates) {
//empty for now for testing
}
...
customElements.define(streetViewCard.is, streetViewCard);
然后使用这个元素,给它和
streetViewCard
this.streetViewCard = document.querySelector("streetViewCard");
console.log(streetViewCard); //this logs the element to the console OK, it's NOT null
streetViewCard.updateLocation(feature.geometry.coordinates);
这是一个错误
Uncaught TypeError: streetViewCard.updateLocation is not a function
更新
根据评论中的要求
console.log(streetViewCard)
是:
class streetViewCard extends Polymer.Element {
static get is() {
return 'street-view-card';
}
static get properties() {
return {
title: {
type: String,
value: 'Street Vâ¦