【问题标题】:Vue code doesn't show up with Webpack Bundle TrackerWebpack Bundle Tracker 不显示 Vue 代码
【发布时间】:2021-08-28 02:05:33
【问题描述】:

我同时运行 vue 和 django。 我已经安装了 webpack_loader 并将其安装在已安装的应用程序中。 我在 settings.py

中有 WEBPACK_LOADER
WEBPACK_LOADER = {
        'DEFAULT': {
            'BUNDLE_DIR_NAME': 'dist/',
            'STATS_FILE': os.path.join(BASE_DIR, 'frontend', 'webpack-stats.json'),
        }
}

frontend 是创建 vue 时的名称。 这里有更多细节KeyError at / 'assets' and ModuleNotFoundError: No module named 'webpack_loader'

我的页面来源来自 http://localhost:8000/ 看起来像这样

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>QuestionTime</title>
</head>
<body>
    
    <h1>Vue JS</h1>

    <noscript>
        <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
    </noscript>
    <div id="app"></div>
    
    <!-- built files will be auto injected -->
    <script type="text/javascript" src="http://0.0.0.0:8080/bundle.js" ></script>

</body>
</html>

我的页面来源来自 http://localhost:8080/ 看起来像这样

<!DOCTYPE html>
<html lang="">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <link rel="icon" href="/favicon.ico">
    <title>hello-vue</title>
  <link href="/js/about.js" rel="prefetch"><link href="/js/app.js" rel="preload" as="script"><link href="/js/chunk-vendors.js" rel="preload" as="script"></head>
  <body>
    <noscript>
      <strong>We're sorry but hello-vue doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
    </noscript>
    <div id="app"></div>
    <!-- built files will be auto injected -->
  <script type="text/javascript" src="/js/chunk-vendors.js"></script><script type="text/javascript" src="/js/app.js"></script></body>
</html>

当我使用 (django-webpack-loader 1.0.0) 时,我得到KeyError at /

当我使用 (django_webpack-loader 0.7.0) 时,我没有收到任何错误,但 vue 代码没有显示(但我在 localhost:8080 看到它)。

【问题讨论】:

    标签: python-3.x django vue.js webpack django-3.2


    【解决方案1】:

    刚开始工作今天,我什么都没做,就开始工作了。我尝试了 2 次用相同的代码创建一个新项目,再次下载了所有的东西。

    没用。但是后来我的vue代码突然停止工作了。我打开和关闭了服务器。然后我看到我的vue代码已经更新了。 然后我去 localhost:8000 看看它是否有效,它确实有效。

    我相信上帝修复了它。不知道还会是什么。

    【讨论】:

      猜你喜欢
      • 2020-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-08
      相关资源
      最近更新 更多