html

<input type="text" id="input1">
<input type="text" id="input2">
<input type="text" id="input3">
<button id="btn">生成文件并下载</button>

js

const input1 = document.getElementById('input1');
const input2 = document.getElementById('input2');
const input3 = document.getElementById('input3');
const btn = document.getElementById('btn');

// 绑定按钮点击事件
btn.addEventListener('click', () => {
  // 获取输入框的文本内容
  const text1 = input1.value;
  const text2 = input2.value;
  const text3 = input3.value;

  // 拼接文本
  const content = `框1${text1}框2${text2}框3${text3}`;

  // 创建Blob对象
  const blob = new Blob([content], { type: 'text/plain' });

  // 创建下载链接并模拟点击下载
  const link = document.createElement('a');
  link.href = URL.createObjectURL(blob);
  link.download = '文件名.后缀';
  link.click();
});