django+vue is used as the back-end and front-end. I want to pass some back-end configuration to the front-end page when rendering the home page:
class HomePageView(TemplateView):
template_name="index.html"
def get_context_data(self, **kwargs):
context = super(HomePageView, self).get_context_data(**kwargs)
context["arg1"] = "12345"
context["arg2"] = "67890"
return context
urlpatterns = [
url(r"^admin/", admin.site.urls),
url(r"^$", HomePageView.as_view()),
]
but the index.html from the front-end vue build is very simple. How can the js in the vue access the context parameters given to it by the backend?
<body>
<div id=app>{{ arg1 }}</div>
<script type=text/javascript src=/static/js/manifest.ab01a7ddcd228431bc0f.js></script>
<script type=text/javascript src=/static/js/vendor.4be9c4044c880f3a85ed.js></script>
<script type=text/javascript src=/static/js/app.11129f6d90cce37c7348.js></script>
</body>