the class defined in a module then introduces the module in the entry file, but all vue components cannot be displayed. Cannot call a class as a function
is our class file written correctly? Can I change it, everyone? What should I do if I want to use this validatePass
method of the class in the vue component?
index.js
const base = class {
validateContent (value) {
let str = value.replace(/(^\s*)|(\s*$)/g, "")
let strlen = str.length
if (strlen > 500) {
return ""
} else if (strlen === 0) {
return ""
}
}
}
export default base
Import index.js into the entry file
import Base from "./common/index.js"
Code of the Release component
<template>
<div>
<el-input type="textarea" v-model="msg" :rows="5" :autosize="{ minRows: 5, maxRows: 6}"></el-input>
<button @click="release(555)">aaa</button>
</div>
</template>
<script>
export default {
name: "Release",
data () {
return {
msg: ""
}
},
methods: {
release (str) {
const base = new Base()
console.log(base)
}
}
}
</script>
<style scoped>
</style>