简体   繁体   中英

django and vue.js production error:nothing shows up after runinng npm build and linking static files in django

i have connected django to vue using webpack loader before running the command npm build everythig was fine by running both terminals everything's working fine but just after running that command and connecting the static file and when i tried to check localhost:8000(defaul django server) i dont see anything not even in console no error and there is nothing

here is my base.html file

<

!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Question Time</title>
        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
        <link href="https://fonts.googleapis.com/css?family=Playfair+Display" rel="stylesheet">
        {% block style %}
        {% endblock %}
    </head>
    <body>
        {% block content %}
        {% endblock %}


    </body>
    {% block js %}
    {% endblock %}
</html>

and here is my index.html

{% extends "base.html" %}
{% load static %}
{% block style %}
<link rel="stylesheet" href="{% static 'bundle.css' %}">
{% endblock %}


{% block content %}
<noscript>
    <strong>We're sorry but frontend doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
{% endblock %}

{% block js %}
<link rel="stylesheet" href="{% static 'bundle.js' %}">
{% endblock %}

i have tried removing dist folder from vue i have tried removing all the static links which casused this issue but its of no use https://stackoverflow.com/questions/47034452/how-to-run-production-site-after-build-vue-cli tried this solution as well but still its of no use

You need to add {% load render_bundle from webpack_loader %}

!DOCTYPE html>
{% load render_bundle from webpack_loader %}
<html lang="en">
...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM