'The library has not yet been initialized' 当我在 nuxtjs 中使用 @microsoft/teams-js
'The library has not yet been initialized' when I use @microsoft/teams-js in nuxtjs
这发生在我尝试在 nuxtjs 中使用@microsoft/teams-js 进行单点登录 (SSO) 时。
<template>
<Tutorial />
</template>
<script>
export default {
name: 'IndexPage',
async mounted () {
const microsoftTeams = await import('@microsoft/teams-js')
// console.log('client => ', microsoftTeams)
microsoftTeams.authentication.getAuthToken({
successCallback: (token) => {
console.log('token', token)
microsoftTeams.appInitialization.notifySuccess()
},
failureCallback: (message) => {
// console.log('error', message)
microsoftTeams.appInitialization.notifyFailure({
reason: microsoftTeams.appInitialization.FailedReason.AuthFailed,
message
})
},
resources: ['']
})
}
}
</script>
enter image description here
根据文档,在调用其他方法之前初始化库:
microsoftTeams.initialize()
这当然仅在 运行 在 Teams 应用程序(选项卡或个人)中有效
这发生在我尝试在 nuxtjs 中使用@microsoft/teams-js 进行单点登录 (SSO) 时。
<template>
<Tutorial />
</template>
<script>
export default {
name: 'IndexPage',
async mounted () {
const microsoftTeams = await import('@microsoft/teams-js')
// console.log('client => ', microsoftTeams)
microsoftTeams.authentication.getAuthToken({
successCallback: (token) => {
console.log('token', token)
microsoftTeams.appInitialization.notifySuccess()
},
failureCallback: (message) => {
// console.log('error', message)
microsoftTeams.appInitialization.notifyFailure({
reason: microsoftTeams.appInitialization.FailedReason.AuthFailed,
message
})
},
resources: ['']
})
}
}
</script>
enter image description here
根据文档,在调用其他方法之前初始化库:
microsoftTeams.initialize()
这当然仅在 运行 在 Teams 应用程序(选项卡或个人)中有效