聚合物动画页面无法更改页面
Polymer animated-pages can't change page
单击 logincard 元素中的按钮时无法更改页面。
在 logincard 元素中,我将按钮的点击设置为 {{onSignUp}}
我该怎么办?我收到错误消息:Uncaught TypeError: Cannot read 属性 '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>
虽然我没有使用 core-animated-pages
的经验,但我非常怀疑
this.pages = document.querySelector('core-animated-pages');
会得到你想要的东西,因为元素可能存在于阴影中 DOM。
尝试
this.pages = document.querySelectorAll('html /deep/ core-animated-pages');
看看这是否解决了您的类型错误。
单击 logincard 元素中的按钮时无法更改页面。 在 logincard 元素中,我将按钮的点击设置为 {{onSignUp}}
我该怎么办?我收到错误消息:Uncaught TypeError: Cannot read 属性 '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>
虽然我没有使用 core-animated-pages
的经验,但我非常怀疑
this.pages = document.querySelector('core-animated-pages');
会得到你想要的东西,因为元素可能存在于阴影中 DOM。
尝试
this.pages = document.querySelectorAll('html /deep/ core-animated-pages');
看看这是否解决了您的类型错误。