首先,我在StackOverflow上找到了another topic about that error,但它并没有帮助我。
我试图在用户登录(或退出)我的网站时告诉Shiny,但我收到以下错误:
lwd.js:8 Uncaught(in promise)TypeError:Shiny.onInputChange不是函数 在LoginWithDiscord._onlogin(lwd.js:8) 在LoginWithDiscord.init(lwd.js:39) 在(指数):24
我真的不明白为什么,因为我使用SHINY。我在我的工作机器上尝试了相同的方法,效果非常好。
有一些我的代码,如果你想要更多只是问:)
this._onlogin = () => {
let user = discord.fetchUser();
Shiny.onInputChange('discordupfp', user.avatarURL);
Shiny.onInputChange('discorduid', user.id);
Shiny.onInputChange('discordusername', user.username);
};
this._onlogout = () => {
Shiny.onInputChange('discord-logout', 1);
};
server.r:
discordpfp = NULL
discorduid = NULL
discordusername = NULL
lang = "us"
observeEvent(input$discordpfp, {
userpfp = input$discordpfp
})
observeEvent(input$discoruid, {
discorduid = input$discorduid
})
observeEvent(input$discordusername, {
userpfp = input$discordusername
})
discordarea = reactive({
if(is.null(discorduid)){
#No problem on showing my id
tags$button(onClick="discord.login('342488102318637059', Scope.Identify)", class="login-button", "LOGIN")
} else {
tags$img(
src=discordpfp,
class="discord-image",
width="75"
)
div(id="poupup-element",
div(class="discord-poupup",
tags$button(onClick="discord.logout()", class="logout-button", "LOGOUT")
)
)
}
})
output$discordarea = renderUI({
return(discordarea())
})
observeEvent(input$discordlogout, {
discordpfp = NULL
discorduid = NULL
discordusername = NULL
lang = "us"
})