vue.js 에서 위 챗 을 사용 하여 invalid signature 문 제 를 해결 합 니 다(완벽 하 게 해결)
<template>
  <a class="btn" @click="scan">   </a>
</template>(그 중에서 appId,timestamp,nonceStr,signature 는 배경 에서 가 져 와 야 합 니 다.현재 웹 페이지 의 URL 을 전송 해 야 합 니 다.\#와 그 뒷부분 은 포함 되 지 않 습 니 다.location.href.split('\#')[0]가 져 오기)
wx.config({
  debug: true, //       ,     api         alert  ,         ,   pc   ,       log  ,  pc      。
  appId: '', //   ,        
  timestamp: , //   ,        ,    
  nonceStr: '', //   ,        
  signature: '',//   ,  
  jsApiList: [] //   ,     JS    ,  :['chooseImage','previewImage','uploadImage']
})
wx.ready(function(){
 
  // config        ready  ,          config        ,
   config           ,                   ,         ready            。             ,       ,     ready   。
});
export default {
		data() {
			return {
				
			}
		},
		methods: {
			init(){
				let url = location.href.split('#')[0];//     fullUrl        url(  #    )
				this.$axios.get("/api/wx/jsdk/config",{params:{
					url:url
				}}).then(res => {
					if(res.success){
						window.wx.config({
						  debug: false,
						  appId: res.data.appId, //   ,        
						  timestamp: res.data.timeSpan, //   ,        
						  nonceStr: res.data.nonceStr, //   ,        
						  signature: res.data.sinature, //   ,  
						  jsApiList: ['checkJsApi', 'scanQRCode'] //   ,     JS    
						})
					}else{
						alert(res.msg);
					}
				})
			},
			scan(){
				window.wx.ready(function() {
					wx.checkJsApi({
						 jsApiList : ['scanQRCode'],
						 success : function(res) {
							if (res.checkResult.scanQRCode === true) {
								 wx.scanQRCode({ //        
								  needResult: 1, //    0,         ,1         ,
								  scanType: ['qrCode', 'barCode'], //              ,      
								  success: function (res) {
										let result = res.resultStr //  needResult   1  ,       
										window.location.href = result;//            
								 }
							 })
							} else {
							  alert('  ,             ')
							}
							
						 },
						 
						 fail: function (res) { //   getNetworkType        
						  alert('fail' + res)
						 }
						
					});
				});
				
				window.wx.error(function(res) {
					alert("   :" + res.errMsg);//         wx.config    ,         ,            。
				});
					
			}
		},
		mounted() {
			this.init();
		}
	}vue.js 에서 위 챗 을 사용 하여 invalid signature 문 제 를 해결 하 는 글 을 소개 합 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Fastapi websocket 및 vue 3(Composition API)1부: FastAPI virtualenv 만들기(선택 사항) FastAPI 및 필요한 모든 것을 다음과 같이 설치하십시오. 생성main.py 파일 및 실행 - 브라우저에서 이 링크 열기http://127.0.0.1:...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.