|
[多端开发]
dispatch script failed. ReferenceError: $api is not defined at main.js
[复制链接]
<template>
<safe-area class="page">
<view class="header">
<text class="title">首页</text>
</view>
<view class="body" id="mybody">
<text class="h1">{module}</text>
<img class="img" src="../../image/img.png" />
<text class="p">{text}</text>
</view>
</safe-area>
</template>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript">
import config from '../../script/configModule'
export default {
name: 'main',
apiready() {
this.data.module = config.data[0].moduleText;
$api.html($api.byId('mybody'),'<h1>world</h1>');
},
data() {
return {
module: '',
text: '我是text'
};
},
methods: {}
};
</script>
<style>
.page {
height: 100%;
background: #fff;
}
.header {
height: 44px;
justify-content: center;
align-items: center;
}
.title {
font-size: 16px;
font-weight: bold;
color: #333;
}
.body {
background: #f5f6f7;
flex: 1;
}
.h1 {
font-size: 22px;
font-weight: bold;
color: #333;
text-align: center;
margin: 50px;
}
.img {
max-width: 100%;
}
.p {
color: #aaa;
text-align: center;
font-size: 16px;
margin: 15px;
}
</style>
|
|