Re-render Tweet button via JS

2019-02-02 06:39发布

I used to use this snippet to re-render a Tweet button.

var tweetButton = new twttr.TweetButton(twitterScript);
twttr.render();

But it looks like widgets.js (http://platform.twitter.com/widgets.js) has been modified so twttr.TweetButton is no longer a constructor.

Can anyone help with this issue?

7条回答
Evening l夕情丶
2楼-- · 2019-02-02 07:22

For anyone stumbling onto this, there's a new, easier way to do it (as of 5/28/12 if not before). A quick glance didn't find it in the documentation, but you can do twttr.widgets.load(). That'll [re]load all the widgets on the page.

EDIT: It is documented, after all. Check out this page's "Optimization" section (which you can't link to directly)

查看更多
登录 后发表回答