Vue-CLI 3仅用于生产构建,在lib Vue组件中使用动态导入时出现块加载器错误

问题描述

我正在尝试构建图标库vue组件,并基于道具动态导入svg。我想对每个图标进行编码拆分,因此对于仅使用1个图标的应用程序,我们不会加载数百个图标。

library(shiny)
library(rhandsontable)

shinyApp(
  ui = fluidPage(
    actionButton("show","Show data",width = "100%"),rHandsontableOutput("data_table")
  ),server = function(input,output) {
    
    rv <- reactiveValues(
      # Triggers
      pressed_first_time = 0,confirm_module = TRUE,save_module = TRUE,table_change = TRUE
    )
    
    observeEvent(input$show,ignoreInit = TRUE,{
      if (rv$pressed_first_time == 0){
        rv$pressed_first_time <- 1
        rv$table_change <- isolate(!rv$table_change)
        cat("pressed_first time")
      } else {
        rv$pressed_first_time <- 1
        rv$confirm_module <- isolate(!rv$confirm_module)
      }
    })
    
    observeEvent(rv$confirm_module,{
      confirmSweetAlert(
        session = session,inputId = session$ns("show_confirmation"),title = "Be careful,your changes might be lost",text = "Do you want to save your changes?",type = "question",btn_labels = c("Cancel","Save"),btn_colors = NULL,closeOnClickOutside = FALSE,showCloseButton = FALSE,html = FALSE
      )
      
    })
    
    observeEvent(input$show_confirmation,{
      if (isTRUE(input$show_confirmation)) { 
        sendSweetAlert(
          session = session,title = "Saved",text = "Updated data has been successfully saved",type = "success"
        )
        rv$table_change <- isolate(!rv$table_change)
        cat("saving module")
      } else {
        return()
      }
    })
    
    data_to_modify <- eventReactive(rv$table_change,{

      rhandsontable(mtcars)
    })
    
    # handson_df <- eventReactive(rv$table_change,{
    #   cat("create handsons")
    #   req(data_to_modify())
    #   rhandsontable(data_to_modify())
    # })
    
    
    output$data_table <- renderRHandsontable({
      cat("plot module")
      req(data_to_modify())
      data_to_modify()
      # htmlwidgets::onRender(handson_df(),change_hook)
      
    })
  }
)

此组件可在开发人员中使用,并且可以很好地加载所有图标,但是在为生产而构建并导入到其他vue应用程序中时,出现此错误:

<template>
  <keep-alive>
    <component
      :is="svgLoader" 
      :id="name"
      :width="cWidth"
      :height="cHeight"
    />
  </keep-alive>
</template>

<script>
export default {
  name: 'SvgLoader',props: {
    name: {
      default: '',type: String,},width: {
      type:  String,default: ''
    },height: {
      type: String,default: ''
    }
  },data() {
    return {
      defaultWidth: '',defaultHeight: ''
    }
  },computed: {
    svgLoader() {
      const name = this.name
      return () => import(
        /* webpackChunkName: "[request]" */
        './assets/' + name + '.svg').then(m => m.default)
    },cHeight() {
      return this.height ? this.height : this.defaultHeight
    },cWidth() {
      return this.width ? this.width : this.defaultWidth
    }
  },mounted () {
    if (this.name) {
      this.svgLoader().then(svg => {
        this.$nextTick(() => {
          let svgElement = document.getElementById(this.name)
          let svgDims = svgElement.getAttribute('viewBox') ? svgElement.getAttribute('viewBox').split(' ') : [0,16,16]
          this.defaultWidth = svgDims[2] + 'px'
          this.defaultHeight = svgDims[3] + 'px'
        })
      })
    }
  }
}
</script>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...