javascript - 如何绑定以 url 表示的 api 数据?
问题描述
http://www.dnd5eapi.co/api/spells/
{
"count": 319,
"results": [
{
"name": "Acid Arrow",
"url": "http://www.dnd5eapi.co/api/spells/1"
},
“网址”:“ http://www.dnd5eapi.co/api/spells/1 ”
{
"_id": "5bce91f95b7768e7920184d6",
"index": 1,
"name": "Acid Arrow",
"desc": [
"A shimmering green arrow streaks toward a target within range and bursts in a spray of acid. Make a ranged spell attack against the target. On a hit, the target takes 4d4 acid damage immediately and 2d4 acid damage at the end of its next turn. On a miss, the arrow splashes the target with acid for half as much of the initial damage and no damage at the end of its next turn."
],
"higher_level": [
"When you cast this spell using a spell slot of 3rd level or higher, the damage (both initial and later) increases by 1d4 for each slot level above 2nd."
],
"page": "phb 259",
"range": "90 feet",
const axios = require("axios");
const url =
"https://cors-anywhere.herokuapp.com/http://dnd5eapi.co/api/spells";
axios
.get(url)
// .then(response => console.log(response.data.results))
.then(res => {
this.classes = res.data.results;
})
.catch(error => console.log(error));
<v-card v-for="spells in classes">
<v-card-title>{{ spells.name }}</v-card-title>
<p>{{ spells.url }}</p>
</v-card>
我正在使用 Vue 进行测试,但这是我遇到问题的基本想法。我感到困惑的问题是我试图绑定来自“url”的数据以显示来自 URL 的其他数据。我将如何到达“url”端点并显示数据?
解决方案
推荐阅读
- javascript - 赛普拉斯等待 xhr 日志记录
- r - 是否有以日期范围为条件镜像 EXCEL COUNTIFS 的 R 函数?
- ansible - 在 Ansible 中使用 ipaddr 过滤对象列表
- c# - 设置图像源导致内存泄漏(wpf,c#)
- jquery - 在循环外检索每个循环中设置的变量值
- javascript - 如何在 Node.js 模块中编写移动方法,该模块为井字游戏导出游戏类?
- batch-file - 如何将文件从子文件夹传输到两个级别的文件夹,同时将文件保留在主文件夹中并删除子文件夹?
- java - How to sum the adjacent values around a given location in a 2D Array (Matrix)?
- angular - Injection Dependency in Angular
- mysql - SQL count 函数在 equals 运算符和 in 运算符之间的区别