【问题标题】:In Office add-in, where is the taskpane.js script being loaded?在 Office 加载项中,taskpane.js 脚本在哪里加载?
【发布时间】:2022-01-13 04:07:40
【问题描述】:

我正在关注一个简​​单的 Word Office 加载项示例。在taskpane文件夹中,有一个taskpane.js,但taskpane.html只有以下脚本标签:

<script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js"></script>

似乎没有加载 taskpane.js? taskpane.js 在哪里加载?

【问题讨论】:

  • 您的清单文件是否引用了 taskpane.js 文件?
  • 不,它指的是taskpane.html

标签: html ms-word office365 office-js office-addins


【解决方案1】:

Webpack 会为你做到这一点!

如果您转到webpack.config.js 文件,您可能会发现以下插件声明:

 new HtmlWebpackPlugin({
        filename: "taskpane.html",
        template: "./src/taskpane/taskpane.html",
        chunks: ["polyfill", "taskpane"],
      }),

在构建外接程序时将所需的引用添加到 HTML 页面。

【讨论】:

    【解决方案2】:

    添加到尤金的答案。根目录下的webpack.config.js 也有加载 JavaScript 文件的代码:

    entry: {
      polyfill: ["core-js/stable", "regenerator-runtime/runtime"],
      taskpane: "./src/taskpane/taskpane.js",
      commands: "./src/commands/commands.js",
    },
    

    【讨论】:

      猜你喜欢
      • 2017-11-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多