[英]Failed to resolve module specifier "sortablejs". Relative references must start with either "/", "./", or "../"
[英]Failed to resolve module specifier "vee-validate". Relative references must start with either "/", "./", or "../"
我們不使用npm
因為我們在Django
項目上工作,但我們在模板中使用VueJS
。 現在我們成功使用了vee-validate
並且我需要覆蓋錯誤消息。 問題是我找不到除了importing
之外的其他方法,而且我不能這樣做。
我試圖創建一個新的<script type="module">
這顯然不起作用:
Failed to resolve module specifier "vee-validate". Relative references must start with either "/", "./", or "../".
這是我的代碼。
<script src="https://unpkg.com/vee-validate@2.0.0-beta.25"></script>
<script type="module">
import {localize} from 'vee-validate';
localize({
en: {
messages: {
required: 'xxxxxxxx',
min: 'this field must have no less than {length} characters',
max: (_, {length}) => `this field must have no more than ${length} characters`
}
}
});
</script>
您有任何想法如何覆蓋消息嗎?
VeeValidate 可以很好地包含在<script>
(如文檔所示)
包含后,全局VeeValidate
對象可用。 如果您使用非 beta版本(例如2.0.9 ),這將起作用(是否有理由使用舊版本和beta版本?)
<script type="text/javascript">
VeeValidate.Validator.localize({
en: {
messages: {
required: 'xxxxxxxx',
min: 'this field must have no less than {length} characters',
max: (_, {length}) => `this field must have no more than ${length} characters`
}
}
});
</script>
不幸的是,文檔中的script
使用示例並不多,因此您必須自己探索 API(只需執行console.log(VeeValidate)
)。 使用 NPM 版本會更容易 100%...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.