lfkabb 2019-06-11 09:24 采纳率: 0%
浏览 3217

微信小程序如何引用外部(其他)页面的js

微信小程序在用到template 模板的时候,引入了wxml ,wxss ,但是在引入js的时候出了问题,具体情况如下:
在template.wxml 里面定义模板:

<template name = "msgItem">
  <view class='hospList' wx:for="{{hospListArray}}">
    <view class='hospImage'><image src='{{item.imageSrc}}'></image> </view>
    <view class='hospRight'>
      <view class='rightFirstLine'>
        <view class='hospTitle'>{{item.hospName}}</view>
        <view class='hospLevel'>{{item.hospLevel}}</view>
      </view>
      <view class='RightSecond '>
        <text>{{item.hospAdress}}</text>
      </view>
      <view class='RightSecond'>
        <text class='survey'>{{item.hospSurvey}}</text>
      </view>
    </view>
  </view>
</template>

然后在index.wxml里引用:

<import src="../template/template.wxml"/>
<template is="msgItem" data="{{...item}}"/>

在index.wxss里也相应的引用:

@import "/template/template.wxss";

但是由于template.js未引用过来,数据绑定不能渲染出来。恳求大神指点,js该如何引用。不慎感激。
文件结构是这样的:

图片说明

  • 写回答

2条回答 默认 最新

  • 自我抉择 2019-06-11 11:27
    关注

    首先需要使用jqure插件,使用jqure和js
    导入进去就好了,在head标签内

    评论

报告相同问题?

悬赏问题

  • ¥15 Wps js宏根据条件删除指定行
  • ¥15 wireshark里如何将加密的ssh数据包解密
  • ¥15 knn中predict_proba的结果不准的问题
  • ¥15 AT89C51单片机代做
  • ¥50 对于阴影比较重的图片如何matchTemplate?
  • ¥30 docker构建zabbix镜像
  • ¥15 有人帮我看看这个程序哪里出错了吗,大学生结课要求,能给一些指导就更好了🥺🥺(语言-c++)
  • ¥200 模拟电子桌面游戏的请求的参数问题
  • ¥15 单闭环无静差调速仿真
  • ¥60 想要在银河麒麟v10里面安装XMind如何安装