為了讓新聞直接使用Twitter,而不需要再開發(fā)一套新聞系統(tǒng)。
類似效果:https://ethereum.org/ ,以太坊的最下面,有以太坊twitter的文章列表。
1. 科學(xué)上網(wǎng)之后打開twitter -> 設(shè)置 -> 小工具
原諒我使用了中文
這時(shí),會(huì)跳轉(zhuǎn)一個(gè)網(wǎng)頁(yè):publish.twitter
然后在輸入框輸入你想引用的twitter地址,點(diǎn)擊確認(rèn)( -> )
eth的twitter
選擇樣式:
展示樣式
然后copy code:
案例
示例代碼:
<a class="twitter-timeline" href="https://twitter.com/ethereumproject?ref_src=twsrc%5Etfw">Tweets by ethereumproject</a> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
然后將這段代碼插入到你的html中即可運(yùn)行。
2. vue中使用上面的代碼
由于我們一般使用components做組件化,在組件中是不可以使用script標(biāo)簽的,所以在vue中,可以將script那一段直接放入index.html中 head的底部:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!-- something your code -->
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</head>
<body>
<div id="app"></div>
</body>
</html>
然后在components中:
<div class="twitter-area">
<a class="twitter-timeline" href="https://twitter.com/ethereumproject?ref_src=twsrc%5Etfw">Twitter by ETH, Loading...</a >
</div>
在網(wǎng)頁(yè)中的效果:
效果
The end.