跳至主要內容

原神好句API

ymh0000123小于 1 分钟

原神好句API

通过JS调用

html代码

<div id="ys"></div>
推荐 通过unpkg调用

js代码

//原神好句api by没用的小废鼠
fetch('https://unpkg.com/genshin-good-words/Good-words.txt')
.then(response => response.text())
.then(data => {
  const lines = data.split('\n');
  const randomLine = lines[Math.floor(Math.random() * lines.length)];
  document.getElementById('ys').innerText = randomLine;
})
.catch(error => {
  console.error('Error fetching ys:', error);
});

cdn引入

html代码

<div id="ys"></div>
通过unpkg引入
<script src="https://unpkg.com/genshin-good-words/script_npm.js"></script>

demo

See the Pen 原神好句API by ymh0000123 on CodePen.