How vue uses methods of classes

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>
Sep.24,2021

landlord, first of all, understand and understand what Vue.use () is used for and what parameters to receive. Here you can refer to the official document, portal .

so change it to Vue.use (new base ()) .

if you simply define a class and need a reference, the usage is actually very simple.

</a><br>:

class Func{
  validatePass (value) {
  },
  validateUser (value) {
  },
}
let getFunc = new Func();
export default getFunc;

//
import getFunc from './common/index.js'
//
getFunc.validatePass()
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37273-2c064.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37273-2c064.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?