Use PyeChartsco in Django

2023-01-22   ES  

// Needless to say
npm install clipboard

How to use:

// template I have seen a lot of information, but in Vue, it is not recommended to use the REF method as much as possible
<span
class="tag"
ref="copy"
@click="copy"
>{
    {
    newPassword}}</span>
//methods
copy() {
    
      let copy = this.$refs.copy
      let clipboard = new Clipboard(copy, {
    
        text: (trigger) => {
    
          return this.password
        }
      });
      console.log('2');
      clipboard.on("success", (e) => {
    
        console.log('1');
        this.$message({
    message: 'Copy successfully', showClose: true, type: 'success'})
        // Release memory
        clipboard.destroy();
      });
      clipboard.on("error", (e) => {
    
        this.$message({
    message: 'Copy failed,', showClose: true, type: 'error'})
        clipboard.destroy();
      });
    },

—————————————————————————————
The problem of the first click on the first click, the second click to take effect is solved as follows:

After being explored by yourself, two methods came out.
Reason: Look at the picture first
在这里插入图片描述
在这里插入图片描述
Note: Introduced this plug -in in the Vue file. We just instantly instantiated this plug -in when clicking the call method, so the first click has no effect

First: Mount this method in MouNTED, and an example has been created after loading the page, solving the problem of clicking (recommended)

Second: The instance is directly mounted in the mouNTED. You do n’t need to create an instance like the graph above in the method. After the loading page is completed, create an instance.

  mounted(){
    
    this.clipboard = new Clipboard(this.$refs.copy, {
    
        text: (trigger) => {
    
          return this.password
        }
      });
  },
copy() {
    
      this.clipboard.on("success", (e) => {
    
        this.$message({
    message: 'Copy successfully', showClose: true, type: 'success'})
      });
      this.clipboard.on("error", (e) => {
    
        this.$message({
    message: 'Copy failed,', showClose: true, type: 'error'})
        this.clipboard.destroy();
      });
    }

source

Related Posts

Create uboot environment variable BIN file

Use Arduino to control the robotic arm Ethan

bzoj4199 [luogup2178] wine tasting conference [noI2015] (suffix array+and check) Icefox

wire flat meter 5800 all -around program

Use PyeChartsco in Django

Random Posts

Renren Houxun Router TTL flashing

Use Arduino to control the robotic arm Ethan

In the Vue project, realize the function of closing the browser before the browser, FELIX

HOMEBREW Uninstall: FaiLED to Locate Homebrew! Wrong Flyinginthe

SAP-Abap Learning Record (2)