如何设置 tradingView 以适应移动设备
How to set tradingView to fit mobile
我们在pc Web上使用过tradingView,效果很好。
现在我们要开发一个移动设备 web.which,因为我知道 tradingView 是受支持的。
但是,当我在 GitHub https://github.com/tradingview/charting-library-examples
中使用演示时
看起来布局和字体大小不一样right.it不支持移动设备(我已经设置了resize:true,这可能还需要一些带有工具提示的配置?):
不过官网的demo看起来还不错:
我应该配置什么才能很好地支持移动,谢谢
(我试图在 SO 中搜索此类问题,但一无所获)
只需在 public 文件夹 index.html 中添加这一行
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0">
您可以在初始化时在 TradingView 小部件构造函数中将 preset
(如果您有访问权限,可以参考文档 - https://github.com/tradingview/charting_library/wiki/Widget-Constructor#user-content-preset)选项值指定为 "mobile"
。
preset
preset is a name of predefined widget settings. For now, the only
value supported in the preset is mobile.
TradingView.onready(function(){
var widget = window.tvWidget = new TradingView.widget({
/*
Your other options
*/
preset: "mobile"
};
});
演示外观:
我们在pc Web上使用过tradingView,效果很好。 现在我们要开发一个移动设备 web.which,因为我知道 tradingView 是受支持的。 但是,当我在 GitHub https://github.com/tradingview/charting-library-examples
中使用演示时看起来布局和字体大小不一样right.it不支持移动设备(我已经设置了resize:true,这可能还需要一些带有工具提示的配置?):
不过官网的demo看起来还不错:
我应该配置什么才能很好地支持移动,谢谢 (我试图在 SO 中搜索此类问题,但一无所获)
只需在 public 文件夹 index.html 中添加这一行
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0">
您可以在初始化时在 TradingView 小部件构造函数中将 preset
(如果您有访问权限,可以参考文档 - https://github.com/tradingview/charting_library/wiki/Widget-Constructor#user-content-preset)选项值指定为 "mobile"
。
preset
preset is a name of predefined widget settings. For now, the only value supported in the preset is mobile.
TradingView.onready(function(){
var widget = window.tvWidget = new TradingView.widget({
/*
Your other options
*/
preset: "mobile"
};
});
演示外观: