How to combine custom method with mintUI in vue

how do I click on the picture to pop up the prompt box for message box?

<template>
   <div class="upload">
      <div id="show">
        <input type="file" @change="getFile()" ref="file" id="file" multiple accept="image/jpg,image/jpeg,image/png,image/gif">
      </div>
   </div>
</template>

<script>
import { MessageBox } from "mint-ui"

export default {
  name: "Upload",
  methods: {
    show() {
      MessageBox({
        title: "",
        message: "?",
        showCancelButton: true
      });
    },
    getFile (e) {
      var dataArr = []
      var fd
      fd = new FormData()
      var iLen = e.target.files.length
      for (let i = 0; i < iLen; iPP) {
        var reader = new FileReader()
        reader.index = i
        fd.append(i, e.target.files[i])
        reader.readAsDataURL(e.target.files[i])
        reader.fileName = e.target.files[i].name
        reader.onload = function (event) {
          var imgMsg = {
            name: this.fileName, 
            base64: this.result 
          }
          dataArr.push(imgMsg)
          var txt = event.target.result
          var img = document.createElement("img")
          var oDiv = document.createElement("div")
          oDiv.setAttribute("class", "z_addImg")
          oDiv.style.float = "left"
          img.src = txt 
          img.onload = function () {
            oDiv.appendChild(img)
            document.getElementById("show").appendChild(oDiv)
            var imgList = document.getElementsByClassName("z_addImg")
            for (let j = 0; j < imgList.length; jPP) {
              imgList[i].addEventListener("click", show)
            }
          }
        }
      }
    }
  }
}
</script>
Dec.08,2021

thanks for inviting ~ when you click on each picture, you can call MessageBox first. Don't do anything else until you're sure.
another function is also a value, which can be passed as an argument to the function.
can be called directly.

<template>
  <div id="app">
    <img width="25%" src="./assets/logo.png" /> <HelloWorld />
    <div @click="show">showMsg</div>
  </div>
</template>

<script>
import HelloWorld from "./components/HelloWorld";
import { MessageBox } from "mint-ui";

export default {
  name: "App",
  components: {
    HelloWorld
  },
  methods: {
    show() {
      MessageBox({
        title: "",
        message: "?",
        showCancelButton: true
      });
    }
  }
};
</script>

generally does not need the dom action, it is written in the vue template.
you can pass the show function to

in this way.
getFile(e, show = this.show)

or

getFile(e){
let vm = this;
// 
// vm.show
}

all use vue . How can there be code like document.getElementsByClassName ('zealaddImg') . Try to use data-driven thinking to transform imgList into vm in the instance of vue , and then call it through @ click .

Menu