【发布时间】:2021-08-28 02:05:33
【问题描述】:
我同时运行 vue 和 django。 我已经安装了 webpack_loader 并将其安装在已安装的应用程序中。 我在 settings.py
中有 WEBPACK_LOADERWEBPACK_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