为了让新闻直接使用Twitter,而不需要再开发一套新闻系统。
类似效果:https://ethereum.org/ ,以太坊的最下面,有以太坊twitter的文章列表。
1. 科学上网之后打开twitter -> 设置 -> 小工具
原谅我使用了中文这时,会跳转一个网页:publish.twitter
然后在输入框输入你想引用的twitter地址,点击确认( -> )
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中即可运行。
2. vue中使用上面的代码
由于我们一般使用components做组件化,在组件中是不可以使用script标签的,所以在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>
在网页中的效果:
效果
The end.
网友评论