problem description
when trying to integrate vue with django, django was able to find the relevant static file, but reported an error "Uncaught SyntaxError: Unexpected token <"
.
preview
dist
distserve5000
vue-cli 3.0vuebudildist
django
related codes
setting.py
configuration
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": ["dist"],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "dist")
]
urls.py
configuration
urlpatterns = [
path("admin/", admin.site.urls),
re_path(r"", TemplateView.as_view(template_name="index.html"))
]
ask the boss for help!