Click on an item and open the website window according to the obtained website URL information.

1. Modify main.vue

In the/SRC/Components/main. vue component, add a double click event to each entry, double click to open the website window, and inject a JS code:

<template>
  <main>
    // ...
    <div id="items">
      <div 
        // ...
        @dblclick="open(item.url, index)"
      >
        // ...
      </div>
    </div>
  </main>
</template>

<script>

// ...

import buttonJS from './button' 

export default {
  // ...
  methods: {

    // ...

    open(url, index) {
      let readerWin = window.open(url, '', `
        maxWidth=2000,
        maxHeight=2000,
        width=1250,
        height=800,
        backgroundColor=#dedede,
        nodeIntegration=1,
        contextIsolation=1
      `)

      readerWin.eval(buttonJS)
    }
  }
}
</script>
Copy the code

2, the Button. Js

Create/SRC/components/button. Js, write to the injection of js code:

export default `
  alert('hello.')
`
Copy the code