我对JavaScript和jQuery都是陌生的,在我的Visual Studio代码中,它的表达式表示在var se附近,并且它说'}'{"URL":window.location.href,}附近,这将是什么合适的解决方案。

请指教。

这是我的代码:

<script type = "text/javascript">
        function renderSurvey(URL){
        var se = new SurveyEmbed("FM9wg_ghhgvjh","https://formsss.tester.com/","https://jhbjh.kjbkjedge.net/mfpembedconkhtweu/");
        var context = {"URL":window.location.href,};se.renderButton( context);
        }
    </script>

最佳答案

您的代码实际上没有错,我的Visual Studio代码也没有给出任何错误。

不过,您可以提高可读性,我认为类似这样的方法会更干净(其他人可能会不同意):

function renderSurvey(URL) {
  let se = new SurveyEmbed(
    "FM9wg_ghhgvjh",
    "https://formsss.tester.com/",
    "https://jhbjh.kjbkjedge.net/mfpembedconkhtweu/"
  );
  let context = { URL: window.location.href };

  se.renderButton(context);
}

10-05 20:48
查看更多