JS中的parseFloat用于德语表示法

时间:2018-05-17 14:19:36

标签: javascript jquery vue.js

目前我正在尝试实施基于此示例的Vue.js组件:https://jsfiddle.net/mani04/bgzhw68m/

这就是我的资料来源:

Search (_ <> _). (* everything related to not equal *)
Search (?a <> ?b -> ?b <> ?a). (* exactly what you want -
    note that unlike Hoogle, you need to use ?a for a pattern variable *)
Search (?R ?a ?b -> ?R ?b ?a). (* this searches for any symmetry theorem;
    not terribly useful for it's cool that it works *)
Search not "_sym". (* if you know some of the theorem name you can use that, too *)

这适用于computed: { displayValue: { get: function get() { if (this.isInputActive) { return this.price.toString(); } else { return "€ " + this.price.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,"); } }, set: function set(modifiedValue) { var newValue = parseFloat(modifiedValue.replace(/[^\d\.]/g, "")); if (isNaN(newValue)) { newValue = 0; } this.price = newValue; } } } 1.00等值。

现在我想用德语写这些花车的方法:

在德国,我们正在为1,300,500.25撰写1.000.000,50。因此,您会看到:one million and 50 cent,已被替换。

那么如何更改我的脚本以使其符合此表示法呢?这非常重要,我仍然可以使用.

1 个答案:

答案 0 :(得分:3)

您可以使用<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> <!--Load the AJAX API--> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> // Load the Visualization API and the corechart package. google.charts.load('current', { 'packages': ['corechart'] }); // Set a callback to run when the Google Visualization API is loaded. google.charts.setOnLoadCallback(drawChart); // Callback that creates and populates a data table, // instantiates the pie chart, passes in the data and // draws it. function drawChart() { // Create the data table. var data = new google.visualization.DataTable(); data.addColumn('string', 'Topping'); data.addColumn('number', 'Slices'); data.addRows([ ['SK',<%=countSK %>], ['Faze',<%=countFaze%>], ['Astralis',<%=countAstralis%>], ['Nip',<%=countNip %>], ['Cloud9',<%=countCloud%>], ['G2',<%=countG2%>] ['North',<%=countNorth %>], ['VP',<%=countVP%>], ['Mouz',<%=countMouz%>] ['Liquid',<%=countLiquid %>], ['Gambit',<%=countGambit%>], ['Fnatic',<%=countFnatic%>] ['Renegades',<%=countRene %>], ['EnvyUs',<%=countEnvy%>], ['Navi',<%=countNavi%>] ]); // Set chart options var options = { 'title': 'Favorite Team', 'width': 400, 'height': 300 }; // Instantiate and draw our chart, passing in some options. var chart = new google.visualization.PieChart(document.getElementById('chart_div')); chart.draw(data, options); } </script> 替换小数点分隔符,然后使用货币格式分隔符。

例如:

,

我更新了您的fiddle