|
本帖最后由 BIP24956 于 2022-9-12 13:58 编辑
这个我是先在白板上试效果的,成功后复制到我复杂一点的项目里面去,又不行了。说是一个项目只能有一个exportdefault,var只能放到apiready里面等等各种问题。
解决了这些之后终于成功了。
就是BODY里面单独插入text控件,script里的exportdefault里单独插入data输出结果,
apiready里面单独插入var。但是我又想增加mnpopups气泡弹窗模块,这下又难倒我了。
- <template>
- <view class="view_3">
- <frame class="frame_2" bounces="true" scrollToTop="true" scrollEnabled="true" vScrollBarEnabled="true" hScrollBarEnabled="true" softInputBarEnabled="true"></frame>
- <avm-address class="page" v-bind:dataList="list" onresult="onGetResult"></avm-address>
- <text class="text_1">{timeDesc}</text>
- <button class="button_1" tapmode="active" onclick="fnOpen()" style="padding:6px 20px;border:1px solid #dfdfdf;border-radius:4px;background-color:#ffffff00;">按钮</button>
-
- </view>
- </template>
- <script type="text/javascript" src="script/api.js"></script>
- <script>
- import '../../components/avm-address/avm-address.stml';
- export default {
- name: 'demo-avm-address',
- apiready() {
- var netTime = api.require('netTime');
- this.data.timeMltiSelectorValue = [new Date().getHours(), new Date().getMinutes(), new Date().getSeconds()];
- var date = new Date(1477386005 * 1000);
- this.data.timeDesc = formatDate(new Date());
- var mnPopups = api.require('MNPopups');
- function formatDate(date) {
- let myYear = date.getFullYear();
- let myMonth = date.getMonth() + 1;
- let myWeekday = date.getDate();
- let myHour = date.getHours();
- let myMinute = date.getMinutes();
- let mySecond = date.getSeconds();
- if (myMonth < 10) {
- myMonth = '0' + myMonth;
- }
- if (myWeekday < 10) {
- myWeekday = '0' + myWeekday;
- }
- if (myHour < 10) {
- myHour = '0' + myHour;
- }
- if (myMinute < 10) {
- myMinute = '0' + myMinute;
- }
- if (mySecond < 10) {
- mySecond = '0' + mySecond;
- }
- return `${myYear}.${myMonth}.${myWeekday} ${myHour}:${myMinute}:${mySecond}`;
- }
- console.log(formatDate(new Date()));
- },
- data() {
- return {
- Hour: [],
- minute: [],
- second: [],
- timeMltiSelectorValue: ['', '', ''],
- timeDesc: '',
- list: {
- areaTitle: ' :'
- }
- };
- },
- methods: {
- onGetResult(e) {
- //返回地址
- console.log(JSON.stringify(e.detail));
- }
- }
- };
复制代码
|
|