前端系列“小”问题

记录一些前端小问题

1.在Angular中,html中的onchange事件angular中的function不响应(不使用ng-model和ng-change情况下):

html部分:
onchange="angular.element(this).scope().videoChange()"

angular部分:
$scope.videoChange = function(){
    console.log('hello');
};

2.invalid url domain 错误,方案:微信本地开发,localhost修改成指定网站域名 XXX.com,用来验证微信签名 。

原因分析:微信SDK只信任公众号上填写的域名,当我们在本地调试时,url显示的是localhost,传给微信时,会出现错误“invalid url domain”。

修改本机的hosts文件,路径为“C:\Windows\System32\drivers\etc”,win+R打开命令行,一定要使用管理员权限(可找到cmd的根目录C:\Windows\System32\cmd.exe,右键 管理员身份运行),“cd C:\Windows\System32\drivers\etc”,然后记事本打开“notepad hosts”:(如下图)

在hosts文件最后一行,添加127.0.0.1 www.xxx.com
前面127.0.0.1指的是localhost,将它映射到 www.xxx.com(微信公众号处填写的域名),这样就搞定了。
当你访问 www.xxx.com的时候,其实访问的是localhost。

这里写图片描述

小提示: 如果是微信开发,要在80端口启动项目,否则失效。

猜你喜欢

转载自blog.csdn.net/xiaopeng_han123/article/details/76925343
今日推荐