我有一个文件叫Authenticator.coffee
...
# User
user =
id: '123'
export { user }
# Auth change
auth = firebase.auth()
auth.onAuthStateChanged (u) =>
console.log('Auth state changed ', u.uid)
user.id = u.uid
...并且Page.vue
我想显示id
:
...
{{ uid }}
...
<script>
import { user } from '../providers/Authenticator.coffee';
export default {
data() {
return {
uid: user.id
}
}
}
</script>
显示初始值,但不显示更改。确实发生了变化,我可以看到“身份验证状态已更改”消息与id
.
导入值的变化不会反映在 中data()
吗?
否则我该怎么做?
额外:我可以不做{{ user.id }}
并且template
只script
包含import
吗?