【发布时间】:2019-01-05 23:36:49
【问题描述】:
我使用 Django 作为后端,我想使用 Vue.js 库作为前端。我将它们包含在 CDN 中。问题是脚本的第一行总是得到错误 Uncaught SyntaxError: Unexpected identifier。我怀疑这是因为导入,但我不知道如何使用该库。有任何想法吗?提前致谢。
<!DOCTYPE html>
<html>
<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>title</title>
<link rel="stylesheet" type="text/css" href="/static/fortykwords/style.css" />
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
<script src="https://unpkg.com/@johmun/vue-tags-input/dist/vue-tags-input.js"></script>
</head>
<body>
<ul class="sidebar-nav">
<p>sidebar</p>
<li><a href="/profile/">pepe14</a></li>
<li><a href="/accounts/logout/?next=/submit/">Logout</a></li>
</ul>
<template>
<div>
<vue-tags-input
v-model="tag"
:tags="tags"
@tags-changed="newTags => tags = newTags"
/>
</div>
</template>
<script>
import VueTagsInput from '@johmun/vue-tags-input';
export default {
components: {
VueTagsInput,
},
data() {
return {
tag: '',
tags: [],
};
},
};
</script>
<form action="" method="post">
<input type='hidden' name='csrfmiddlewaretoken' value='fEEj9YrFOkChjlhrZ7HPgDoiJNcnb0ILUrd143icwaZ58No1Ckl8tTr0p9TxRMi7' />
<table>
<tr><th><label for="id_title">Title:</label></th><td><input type="text" name="title" required id="id_title" maxlength="250" /></td></tr>
<tr><th><label for="id_body">Body:</label></th><td><textarea name="body" cols="40" required id="id_body" maxlength="40000" rows="10">
</textarea></td></tr>
<tr><th><label for="id_tags">Tags:</label></th><td><input type="text" name="tags" required id="id_tags" /><br /><span class="helptext">A comma-separated list of tags.</span></td></tr>
</table>
<input type="submit" value="Submit" />
</form>
</body>
</html>
【问题讨论】:
标签: javascript vue.js