问题描述
我的控制器看起来像
library(shiny)
library(tidyverse)
tran_func <- function(pred,trans) {
switch(trans,"None" = pred,"Reciprocal" = 1/pred,"Squared" = pred^2,)
}
ui <- fluidPage(
selectInput("xvar","Select X Variable",choices = names(mtcars),selected = "disp"),selectInput("transform","Select Transformation",choices = c("None","Reciprocal","Squared"),selected = "None"),plotOutput("scatter_good"),plotOutput("scatter_bad")
)
server <- function(input,output,session) {
output$scatter_good <- renderPlot({
mtcars %>%
ggplot(aes_string(x = "hp",y = input$xvar)) +
geom_point()
})
output$scatter_bad <- renderPlot({
mtcars %>%
ggplot(aes_string(x = "hp",y = tran_func(input$xvar,"Squared"))) +
geom_point()
})
}
shinyApp(ui,server)
并且我无法与推子频道关联 但是我总是出错
未定义的属性:App \ Http \ Controllers \ MyController :: $ p
我在做什么错?非常感谢任何可能的帮助!
解决方法
尝试删除代码中的星号(**)
**$this->p->trigger('user-'.$post->user_id,'new-post',$data);**
,
属性$this->p
(p),您尚未设置值
$this->p = Value ;
设置后,您可以使用该信息。
$this->p->trigger('user-'.$post->user_id,$data);
在上面编写的代码中,$this->p
的值为空
$this->null->trigger('user-'.$post->user_id,$data);
实际上,这就是您的用法