惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
博客园 - 司徒正美
WordPress大学
WordPress大学
爱范儿
爱范儿
小众软件
小众软件
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
罗磊的独立博客
博客园_首页
V
V2EX
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Tailwind CSS Blog
大猫的无限游戏
大猫的无限游戏
The Cloudflare Blog
MyScale Blog
MyScale Blog
IT之家
IT之家
H
Help Net Security
Blog — PlanetScale
Blog — PlanetScale
Microsoft Security Blog
Microsoft Security Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Recent Announcements
Recent Announcements
F
Fortinet All Blogs
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
人人都是产品经理
人人都是产品经理

博客园 - androllen

Python yield 关键词 PDF 构成 桌面客户端的主要类型和技术方案 Python 压缩转义 异步删除嵌套文件夹及文件 数据结构 二叉树遍历 数据结构 线性表 JS 字符串转换为函数体 VSCode 配置内部Python项目 缺少模块ModuleNotFoundError C# 基础知识 算法-数列 算法-排序算法 C# 设计模式-简单工厂模式 C# 设计模式 C# Utils .Net 异步与同步 WPF StreamGeometry CSS Flexbox layout 2 CSS Flexbox layout 1
Vue 打开窗口输出文件路径
androllen · 2022-10-05 · via 博客园 - androllen

下面实现的是打开在Electron 中弹出窗口选择文件,

实现的功能:

打开本地窗口,选择文件路径进行输出文件

<template>
  <div class="about">
    <h1>This is an about page</h1>

    <div class="inputfile">
      <a-button type="primary" v-on:click="openFile()">选择文件</a-button>
      <a-input id="textbox" placeholder="open file" v-model="textarea" />
      <input
        type="file"
        name="filename"
        id="open"
        @change="specifiName($event)"
        @input="specifiName($event)"
        style="display: none"
      />
    </div>
  </div>
</template>

<script >
export default {
  data() {
    return {
      textarea: '',
    };
  },
  methods: {
    openFile() {
      document.getElementById('open').click();
    },
    specifiName(e) {
      document.getElementById('textbox').value = document.getElementById('open').files[0].path;
    },
  },
};
</script>
<style >
.inputfile {
  display: flex;
  margin: 10px;
}
#textbox{
  margin-left: 10px;
}
</style>