我想获取我设备的 GPS 位置。我正在使用GeolocatorPlugin for Xamarin 来获取我设备的经度和纬度。我的设备上启用了 GPS。我已经为我的 android manifest 添加了权限,但我仍然收到错误:“发生地理定位错误:未经授权”我该如何解决这个问题?
try
{
var locator = CrossGeolocator.Current;
locator.DesiredAccuracy = 50;
var position = await locator.GetPositionAsync();
entLocation.Text = position.Longitude.ToString() + "," + position.Latitude.ToString();
}
catch (Exception ex)
{
//will catch any general exception and set message in a string
string msg = ex.Message;
await DisplayAlert("error", msg, "ok");
}
Run Code Online (Sandbox Code Playgroud) 我正在使用 chart.js 来显示我的销售额问题是我无法将数据正确转换为带有逗号和两位小数的数字格式。
当数据是整数时,输出是正确的。但是,当我显示平均销售额时,我得到的输出是
平均销售额(无格式) 1000.2017
平均销售额(有格式) 1,000.2,017
总销售额(无格式) 1000
总销售额(有格式) 1,000
如何在javascript中正确格式化输出?
tooltips: {
callbacks: {
label: function(tooltipItem, data) {
var value = data.datasets[0].data[tooltipItem.index];
value = value.toString();
value = value.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return value;
}
}
},
scales: {
yAxes: [{
ticks: {
userCallback: function(value, index, values) {
value = value.toString();
value = value.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return value;
}
}
}]
}
Run Code Online (Sandbox Code Playgroud) 我尝试使用 CSS 和 XAML 更改标签的字体系列,但字体没有反映。我正在尝试在我的应用程序中使用 Montserrat 字体。我怎样才能解决这个问题?
XAML 代码:
<Label StyleClass="label" Text="Sample"/>
Run Code Online (Sandbox Code Playgroud)
CSS代码:
.label{
font-family: Montserrat;
}
Run Code Online (Sandbox Code Playgroud)