最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Shorthand property name are not supported by current Javascript version in PHPStorm - Stack Overflow

programmeradmin4浏览0评论

I have used Jquery getScript and generate html form by Javascript however I got Shorthand property name are not supported by current Javascript version in PHPStorm but my function work as well.

Concern: Before I used PHP to generate html form within another PHP framework but I think I should not used Server script to do that I should use JS to do that but I don't know how is it going on and is it support all browser or not so please give me some idea of this technique because I not yet understand much more about suing DOM and its performance.

Security Concern: if I used Javascript to generate Html form as below script it will less security or bad performance or not?

Another hand if I keep this code inside of HTMl I will never got this errors types.

$(document).ready(function () {
    returnTill('returnTill');
});

function returnTill(returnTill) {

    var chief_opt = '';
    var teller_opt = '';
    $.ajax({
        url:'/teller/return_till_data',
        method:'get',
        dataType:'json',
        timeout:4000,
        async: false,
        success:function (data, status) {
            $.each(data, function(ins, vals){
                if(ins === 'chief') {
                    cheifs = data.chief;
                    for(var key in cheifs){
                        chief_opt += '<option value="'+vals[key].id+'"> '+vals[key].username+' / '+vals[key].account_no+' </option>';
                    }
                }if(ins === 'teller') {  /* Tellers*/
                    tellers = data.teller;
                    for(var key in tellers){
                        teller_opt = '<option value="'+vals[key].id+'"> '+vals[key].username+' / '+vals[key].account_no+' </option>';
                    }
                    loadModale({
                        idSelector: returnTill,
                        title: 'Return Till',
                        labels: ['From','To','Amount','Description'],
                        loadType:'returnTill',
                        forms: {
                            input: {
                                selection: {
                                    from:{chief_opt,class:'form-control', name:'retn_chief',  id:'retn_chief'},
                                    to:{teller_opt, class:'form-control', name:'retn_teller', id:'retn_teller'},
                                },
                                Amount :{type: 'text', name: 'retn_amount',  class: 'form-control', Id: 'retn_amount',  placeholder: '', style: '', value:''},
                                token:{ type: 'hidden', name: '_token', class: 'form-control', Id: 'token', placeholder: '', style: '', value: '{{csrf_token()}}'},
                            },
                            textarea : {
                                description:{class:'form-control', name:'tran_descr', rows:10, id:'tran_descr'}
                            }
                        },script: [
                            '/theme/js/jquery.validate.min.js',
                            '/theme/js/bootstrap-datepicker/js/bootstrap-datepicker.js',
                        ]
                    });
                }
            });

        },error: errorCallback,
    });
}

Errors:

I have used Jquery getScript and generate html form by Javascript however I got Shorthand property name are not supported by current Javascript version in PHPStorm but my function work as well.

Concern: Before I used PHP to generate html form within another PHP framework but I think I should not used Server script to do that I should use JS to do that but I don't know how is it going on and is it support all browser or not so please give me some idea of this technique because I not yet understand much more about suing DOM and its performance.

Security Concern: if I used Javascript to generate Html form as below script it will less security or bad performance or not?

Another hand if I keep this code inside of HTMl I will never got this errors types.

$(document).ready(function () {
    returnTill('returnTill');
});

function returnTill(returnTill) {

    var chief_opt = '';
    var teller_opt = '';
    $.ajax({
        url:'/teller/return_till_data',
        method:'get',
        dataType:'json',
        timeout:4000,
        async: false,
        success:function (data, status) {
            $.each(data, function(ins, vals){
                if(ins === 'chief') {
                    cheifs = data.chief;
                    for(var key in cheifs){
                        chief_opt += '<option value="'+vals[key].id+'"> '+vals[key].username+' / '+vals[key].account_no+' </option>';
                    }
                }if(ins === 'teller') {  /* Tellers*/
                    tellers = data.teller;
                    for(var key in tellers){
                        teller_opt = '<option value="'+vals[key].id+'"> '+vals[key].username+' / '+vals[key].account_no+' </option>';
                    }
                    loadModale({
                        idSelector: returnTill,
                        title: 'Return Till',
                        labels: ['From','To','Amount','Description'],
                        loadType:'returnTill',
                        forms: {
                            input: {
                                selection: {
                                    from:{chief_opt,class:'form-control', name:'retn_chief',  id:'retn_chief'},
                                    to:{teller_opt, class:'form-control', name:'retn_teller', id:'retn_teller'},
                                },
                                Amount :{type: 'text', name: 'retn_amount',  class: 'form-control', Id: 'retn_amount',  placeholder: '', style: '', value:''},
                                token:{ type: 'hidden', name: '_token', class: 'form-control', Id: 'token', placeholder: '', style: '', value: '{{csrf_token()}}'},
                            },
                            textarea : {
                                description:{class:'form-control', name:'tran_descr', rows:10, id:'tran_descr'}
                            }
                        },script: [
                            '/theme/js/jquery.validate.min.js',
                            '/theme/js/bootstrap-datepicker/js/bootstrap-datepicker.js',
                        ]
                    });
                }
            });

        },error: errorCallback,
    });
}

Errors:

Share Improve this question edited Mar 30, 2016 at 10:24 DMS-KH asked Mar 30, 2016 at 10:18 DMS-KHDMS-KH 2,7979 gold badges46 silver badges76 bronze badges 4
  • As object notation, you have to type property and value a: 'something' – kosmos Commented Mar 30, 2016 at 10:38
  • I don't understand why it work and it never got any errors if I place it in document wraper in html. – DMS-KH Commented Mar 30, 2016 at 10:42
  • Javascript interprets that chief_opt is chief_opt = 'something', that's why it works. Anyway, the correct should be to use property and value, that's why phpstorm remarks it as an error – kosmos Commented Mar 30, 2016 at 10:56
  • OH I got it. as the above function I want to used any class or any good feature of JS but I don't know how to work. almost my code always create by function I don't know how to use constructor or class or something refer to OOP structure – DMS-KH Commented Mar 30, 2016 at 15:05
Add a comment  | 

3 Answers 3

Reset to default 20

I perform the following steps in Webstorm to solve the same problem, so it may also work in PHPStorm:

  1. Go to Settings by pressing ALT + CNTRL + S
  2. Click on "Languages and Frameworks"
  3. Click on 'Javascript'
  4. In the "Javascript language version" drop-down, select 'ECMAScript 6'.
  5. Click 'OK'
  6. Now re-open any *.js files you may have previously had open, and notice that the errors are no longer there.

Hope that helps someone.

You can fix it this way:

from:{chief_opt: chief_opt}

So, if you change your code to this:

from:{chief_opt: chief_opt, class:'form-control', name:'retn_chief',  id:'retn_chief'},
to:{teller_opt: teller_opt, class:'form-control', name:'retn_teller', id:'retn_teller'},

You shouldn't get anymore the PHPStorm error.

Hope it helped or at least cleared a little bit. ;)

PHP STORM SOLUTION The error is attributed to the version of your Javascript Setting in PHPSTORM STEPS

  1. Go to settings(preference on macbook)settings/preference and click

  2. Expand the Languages and Frameworks by clicking it click language & frameworks

  3. Click Javascript and change the Javascript language version to the current or ECMAScript6 recommended.select ecmascript

发布评论

评论列表(0)

  1. 暂无评论