这里可变文本需要正确的语法是什么?
$.getJSON('https://www.alphavantage.co/query?
function=BATCH_STOCK_QUOTES&symbols=MSFT&apikey=TRZC92S2OMSWBC8H',
function(data) {
var text = `Date: ${data.{"Stock Quotes"}.[{"1. symbol"}]}<br>
Time: ${data.{"Stock Quotes"}.[{"2. price"}]}<br>`
$(".mypanel").html(text);
});
JSON的原始格式如下:
{
"Meta Data": {
"1. Information": "Batch Stock Market Quotes",
"2. Notes": "IEX Real-Time Price provided for free by IEX (https://iextrading.com/developer/).",
"3. Time Zone": "US/Eastern"
},
"Stock Quotes": [
{
"1. symbol": "MSFT",
"2. price": "100.0600",
"3. volume": "18924367",
"4. timestamp": "2018-07-02 16:45:04"
}
]
}
这个问题与另一个问题的不同之处在于,它使用了getJSON函数。