小编Kas*_*Lee的帖子

Ant Design - 带逗号小数分隔符的货币输入

我想使用 Antd 的<InputNumber />组件作为货币输入,并且我正在使用官方文档建议的内容:

<InputNumber
    min={0}
    size="large"
    style={{ width: 400 }}
    formatter={value => `$ ${value}`.replace(new RegExp(/\B(?=(\d{3})+(?!\d))/g), ',')}
    parser={value => value.replace(new RegExp(/\$\s?|(,*)/g), '')}
/>
Run Code Online (Sandbox Code Playgroud)

但我希望我可以像小数点分隔符一样使用逗号数字:R$ 17.350,70

输入货币信息的正确正则表达式格式和解析器是什么?

javascript regex reactjs antd

5
推荐指数
1
解决办法
8408
查看次数

使用jQuery或Javascript包含PHP文件

我有一个提交表单并加载警报等的Javascript文件.现在我想添加调用或获取.php文件的功能,我尝试使用$.get("mail.php");但它似乎不起作用.

Javascript代码:

$('#myform').on('submit', function(e){
    e.preventDefault();
    $.get($(this).attr('action') + $(this).serialize());
    alert("Thank You! \nTop Up for: <?php echo "$username" ?> Purchased Successfully");
    $.get("mail.php");  //this is the added part to get mail.php//
    location.reload();
Run Code Online (Sandbox Code Playgroud)

PHP - mail.php:

<?php

$to = "stephan@mail.co.za";

$headers = "From: website mail \r\n";

$email_body = "has just toped up his account.\n".

$email_subject = "User Topup Alert";

mail($to,$email_subject,$email_body,$headers);

?>
Run Code Online (Sandbox Code Playgroud)

javascript php forms

4
推荐指数
1
解决办法
2万
查看次数

Lua程序延迟

我如何使用它为我的Lua程序添加2分钟的延迟,这是延迟的代码,但我不知道如何添加延迟.

function sleep(n)
  local t = os.clock()
  while os.clock() - t <= n do
    -- nothing
  end
end
Run Code Online (Sandbox Code Playgroud)

time lua delay

4
推荐指数
1
解决办法
2万
查看次数

按返回按钮时Document.referrer错误

我有一个PHP / Javascript页面,可通过一次登录自动将用户登录到不同的系统。这些是外部站点,除非用户单击“后退”按钮,否则所有站点均正常运行。然后它将它们重定向到它们的来源。

我希望将其重定向回我的主要网站,并避免陷入这种重定向梦night。所以我尝试了document.referrer,但这似乎只能抓住我当前所在的页面,而不是所引用的网站。我错了吗,还是不能这样做?

function myfunc () {
    var frm = document.getElementById("loggedin1");
    if(document.referrer != 'https://someurl') {
        alert(document.referrer);//Just used to see output
        frm.submit();
    }
}

window.onload = myfunc;
Run Code Online (Sandbox Code Playgroud)

如果我可以使它正常运行,则可以else在其中添加一个,然后将其返回到我的网站。

谢谢!

javascript

3
推荐指数
1
解决办法
5512
查看次数

Node.js SendGrid 如何附加 PDF

我正在使用SendGrid在我的 Node.js 应用程序中发送电子邮件。我尝试附加 pdf 的每个组合都以我附加的 pdf 不可读而告终。

我试过了:

fs.readFile('public_html/img/Report.pdf',function(err,data){
    var base64data = new Buffer(data).toString('base64');

    sendgrid.send({
        to        : hexDecode(_.e),
        from      : 'xxxxxxxxx@gmail.com',
        subject   : 'Report',
        
        files      : [{filename:'Report.pdf',content:'data:application/pdf;base64,'+base64data}],
        // files   : [{filename:'Report.pdf',contentType:'data:application/pdf',url:'public_html/img/'Report.pdf'}],
        // files   : [{filename:'Report.pdf',url:'public_html/img/'Report.pdf'}],
        html       : 'bla bla'
Run Code Online (Sandbox Code Playgroud)

有谁知道如何防止“无法加载pdf文档”??

pdf email-attachments node.js sendgrid

3
推荐指数
3
解决办法
2万
查看次数

Firefox上的SVG图像模糊

我正在尝试使用此处提出的SVG技术在Firefox上模糊图像.

然而,这个非常简单的例子不适用于Firefox(我是25版)JSFiddle.

HTML

<img class="blur" src="http://css-plus.com/examples/2012/03/gaussian-blur/i/fence.jpg" />
Run Code Online (Sandbox Code Playgroud)

CSS

.blur {
    filter: url("http://d2oujmlvvb0w9i.cloudfront.net/images/v4/blur.svg#blur")    
} 
Run Code Online (Sandbox Code Playgroud)

有帮助吗?
谢谢

css firefox svg

3
推荐指数
1
解决办法
3289
查看次数

pageYOffset的jQuery等价物是什么?

我有以下代码

window.pageYOffset
Run Code Online (Sandbox Code Playgroud)

什么是jQuery等同于pageYOffset?

jquery

3
推荐指数
1
解决办法
1万
查看次数

通过ng-click将ng-model变量传递给函数

我正在尝试使用带有HTML的select和options标记.数据正在使用ng-repeat,当用户从列表中选择一个项目并按下获取按钮时,我想将用户从选项列表中选择的内容传递给一个函数使用ng-click

HTML

<ul>
 <li class="col-xs-4"><a href="#favourites">Favourites</a></li>
</ul>
<div ng-controller="favouritesController">
 <select class="col-xs-12" name="weather">
  <option ng-repeat="weatherList in weatherLists" ng-model="city">{{weatherList.place}}</option>
 </select>
 <div class="col-xs-12">
  <button type="button" name="button" class="deleFav" ng-click="getFavWeather(city)">Get</button>
 </div>
</div>
Run Code Online (Sandbox Code Playgroud)

Javascript代码

var myApp = angular.module('myApp', ['ngRoute'])

 myApp.controller('favouritesController', function($scope, $http, $rootScope, $route, $location) {
  $scope.getFavWeather = function(weatherList){
   console.log("yes yes yes")
   console.log($scope.city)
  }
 })
Run Code Online (Sandbox Code Playgroud)

javascript angularjs

3
推荐指数
1
解决办法
2万
查看次数

获取所有以班级名称开头的项目

我试图只显示某些div。我决定执行此操作的方法是先隐藏所有以“ page”开头的元素,然后仅显示正确的divs。这是我的(简化)代码:

<form>    
    <input type="text" onfocus="showfields(1);">
    <input type="text" onfocus="showfields(2);">
</form>
<div class="page1 row">Some content</div>
<div class="page1 row">Some content</div>
<div class="page2 row">Some content</div>
<div class="page2 row">Some content</div>
<script>
    function showfields(page){
        //hide all items that have a class starting with page*
        var patt1 = /^page/;
        var items = document.getElementsByClassName(patt1);
        console.log(items);
        for(var i = 0; i < items.length; i++){
            items[i].style.display = "none";
        }

        //now show all items that have class 'page'+page
        var item = document.getElementsByClassName('page' + page);
        item.style.display = …
Run Code Online (Sandbox Code Playgroud)

javascript regex getelementsbyclassname

3
推荐指数
2
解决办法
1万
查看次数

Chrome / Firefox扩展-内容脚本未监听消息

我正在为Chrome和Firefox开发扩展程序,但遇到了问题。

基本上,我正在尝试获取内容脚本来使用侦听消息chrome.runtime.onMessage.addListener(...),但是它似乎不起作用。

我通过从内容脚本发送消息来对其进行了测试。后台脚本(ml.js)的侦听器运行良好,但是内容脚本中的lsitener没收到消息。

您可以在此要点(或下方)中查看代码。

manifest.json

{
    "manifest_version": 2,
    "name": "Messaging Extension",
    "version": "1.0.0",
    "background": {
        "scripts": ["ml.js"]
    },
    "content_scripts": [
        {
            "matches": ["*://*.google.co.uk/*"],
            "js": ["cs.js"],
            "run_at": "document_end"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

ml.js

// When receive message...
chrome.runtime.onMessage.addListener(function(message) {
    if (message.key) {
        console.log('ML: First message received')
        // Send another message
        chrome.runtime.sendMessage({
            'foo': 'bar'
        })
    }
})
Run Code Online (Sandbox Code Playgroud)

cs.js

// Send message to ml.js
chrome.runtime.sendMessage({
    'key': 'value'
})
chrome.runtime.onMessage.addListener(function(message) {
    console.log('CS: Second message received')
}) …
Run Code Online (Sandbox Code Playgroud)

javascript firefox-addon google-chrome-extension firefox-addon-webextensions

3
推荐指数
1
解决办法
1765
查看次数