Skip to content
uniapp调用小白接口sdk
JavaScript
Branch: master
Clone or download
Latest commit 9ca50ab Apr 15, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
okayapi-vue-sdk vue sdk Apr 14, 2019
README.md Update README.md Apr 15, 2019

README.md

yesapi-vue-uniapp-sdk

uniapp调用小白接口sdk-https://github.com/yesapicn/yesapi-vue-uniapp-sdk 首先把okayapi-vue-sdk文件下载后放入components文件夹,然后把okayapi.js的appkey跟appsecret修改成自己的信息(点击查看)。如图在这里插入图片描述

接下来打开根目录下的main.js加入一句并修改成您的域名

 //挂载全局变量okayapiHost AppKey AppSecrect
Vue.prototype.okayapiHost="您的域名";

准备工作结束!调用时只需要加入如下语句

<script>
	import * as okayapi from '../../../components/okayapi-vue-sdk/okayapi.js';


	export default {
		data() {
			return {
				title: 'Music',
				music: {},
				input: '',
				filter: 'name',
				website: 'netease'
			}
		},
		methods: {
			searchOkay: function() {
				var params = {
					s: "App.Music.Search", // 必须,待请求的接口服务名称
					input: this.input,
					filter: this.filter,
					website: this.website
				};
				uni.request({
					url: this.okayapiHost,
					method: 'GET',
					data: okayapi.enryptData(params),
					success: res => {
						console.log(res);
						this.music = res.data.data.music
					},
					fail: res => {
						console.log(res);
					},
					complete: () => {}
				});
			}
		}
	}
</script>

就可以成功调用到小白接口啦

You can’t perform that action at this time.