引入css

<template></template>
<style scoped>

 @import "../assets/common/common.css";

</style>

或者是

<style scoped src="../../static/css/test.css"></style>

引入js

1,在需要的页面引入,

import '../../../static/js/jquery-1.9.1.min.js'   //jq插件

import util from '../../common/js/util'          //自己写的一个js文件。然后可以通过util来引用这个文件里面的函数。比如util.getTime()

 

import { mymixin } from "@/assets/js/mixin";

export default {
  mixins: [mymixin],

然后这个mixin的页面是这样的

import {    
    getSpecialChaptertree,
    getChapterInfoNew,
    getChapterbookletQuestioncategoryInfo,
    addResource
} from "@/api/api";//这里是引入的接口名字以便下面的函数去访问接口
export const mymixin={
    data(){
        return{
        //   num:1,    
        }
    },
    methods:{
      // 获取学段列表
            getStudySection() {
                this.studysectionlist = []
                this.allStudySection.forEach(v => {
                    this.studysectionlist.push(v.studysection)
                })
                this.studysection = this.studysectionlist[0]
                this.getSubjects(this.studysection)
            },

},//methods
}

 

2,在main.js全局引入,每个页面都可以直接使用不必在调用了

//引入echart
import echarts from 'echarts'
Vue.prototype.$echarts = echarts 

然后需要的页面不用引入直接使用 let myChartPie = this.$echarts.init(document.getElementById('chartPie'));

Logo

讨论HarmonyOS开发技术,专注于API与组件、DevEco Studio、测试、元服务和应用上架分发等。

更多推荐