最终答案如下(我查看了使用此包的项目)。
有一个在 Nuxt 上运行的项目。
这些是您应该添加到@tamzid-oronno 的答案的更改
//vue-upload-multiple-image.js
import Vue from 'vue'
import VueLazyload from 'vue-lazyload'
import VueUploadMultipleImage from 'vue-upload-multiple-image'
Vue.use(VueLazyload) // this is from the package installation guide
Vue.component('VueUploadMultipleImage', VueUploadMultipleImage)
并以同样的方式在插件中列出。
//nuxt.config.js
plugins: [
{ src: '~plugins/vue-upload-multiple-image', ssr: false }
]
因此,您将能够使用该包,而无需将其作为标签导入页面。这是在plugin_plus_lazy分支中实现的。
这两个标签都适用于 vue-upload-multiple-image 和 VueUploadMultipleImage。
//your-index-file.vue
<template>
<div id="my-strictly-unique-vue-upload-multiple-image" style="display: flex; justify-content: center;">
<vue-upload-multiple-image
@upload-success="uploadImageSuccess"
@before-remove="beforeRemove"
@edit-image="editImage"
:data-images="images"
idUpload="myIdUpload"
editUpload="myIdEdit"
dragText = "Drag an image here"
browseText = "(or click here to browse)"
primaryText = "Default Image"
markIsPrimaryText = "Set as default image"
popupText = "This image will be set as default"
dropText = "Drag and drop"
accept = image/jpeg,image/png,image/jpg,image/tif,image/tiff
></vue-upload-multiple-image>
</div>
</template>
<script>
export default {
name: "AppUpload",
data(){
return{
file:"",
images: []
}
},
methods:{
uploadImageSuccess(formData, index, fileList) { },
beforeRemove (index, done, fileList) { },
editImage (formData, index, fileList) { },
}
}
</script>
<style scoped>
</style>
要创建静态版本并在本地计算机上对其进行测试,请执行以下操作:
$ npm run generate
# test the project
$ npm install http-server
$ cd dist
$ http-server -p 3000
我还有一个问题 - 为什么它有效?:)