单击logincard元素中的按钮后,我无法更改页面。 在logincard元素中,我已将按钮设置为{{onSignUp}}
我该怎么办?我收到错误消息:Uncaught TypeError:无法读取属性'selected'of null
<core-animated-pages id = "animatedPages" transitions="cross-fade" selected="{{moveCard}}" center >
<section id="0">
<div hero-id="hero" hero>
<moha-logincard token="{{token}}" success="{{success}}" loginurl="{{loginurl}}" signup="{{signup}}" z="{{z}}" onLogin="{{close}}" onSignUp="{{goToSignUp}}">
</moha-logincard>
</div>
</section>
<section id="1">
<div hero-id="hero" hero>
<moha-signupcard success="{{success}}" signupurl="{{signupurl}}" z="{{z}}" onSignUp="{{backToLogin}}"></moha-signupcard>
</div></section>
</core-animated-pages>
</template>
<script>
Polymer('moha-login-page', {
moveCard: "0",
pages:document.querySelector('core-animated-pages'),
signup: false,
token: "",
loginurl: "",
signupurl: "",
z: 2,
close: function () {
//dialógus becsukása ha van
},
goToSignUp: function () {
// var pages = document.querySelector('core-animated-pages');
//var pages = this.$.animatedPages;
this.pages = document.querySelector('core-animated-pages');
console.log(this.pages.selected);
this.moveCard = "1";
this.pages.selected = this.moveCard;
console.log(this.pages.selected);
},
backToLogin: function () {
this.moveCard = 0;
}
});
</script>
答案 0 :(得分:1)
虽然我对core-animated-pages
没有经验,但我非常怀疑
this.pages = document.querySelector('core-animated-pages');
会为你提供你想要的东西,因为元素可能存在于影子DOM中。
尝试
this.pages = document.querySelectorAll('html /deep/ core-animated-pages');
并查看这是否解决了您的TypeError。