zoukankan      html  css  js  c++  java
  • 问题贴 jQuery插件nicescroll问题

    引入插件后   页面首次加载时不会出现滚动条display:none  重新刷新页面后才能出现滚动条  这是什么原因? 

    源码如下   省略了插件。。。

    <style lang="less">
    @import "./framework.less";
    .ivu-select-dropdown {
    border-radius: 0;
    }
    </style>


    <template>
    <div class="framework">

    <!-- 框架头部 开始 -->
    <div class="framework-header">
    <!-- logo -->
    <div class="header-left">
    <img src="../images/logo.svg"></img>
    </div>
    <!-- 面包屑 -->
    <div class="header-middle">
    <breadcrumb-nav :currentPath="currentPath"></breadcrumb-nav>
     
    </div>

    <!-- 左侧内容 -->
    <div class="header-right">

    <!-- <hr-search :searchItem="searchItem"></hr-search> -->
    <sea></sea>
    <!-- <Icon type="location" style="20px; height:20px;"></Icon> -->
    <full-screen v-model="isFullScreen" @on-change="fullscreenChange"></full-screen>
    <lock-screen></lock-screen>
    <message-tip v-model="mesCount"></message-tip>

    <div class="user-dropdown-menu-con">
    <Row type="flex" justify="end" align="middle" class="user-dropdown-innercon">
    <Dropdown trigger="click" @on-click="handleClickUserDropdown">
    <a href="javascript:void(0)">
    <span class="main-user-name">{{ name }}</span>
    <Icon type="arrow-down-b"></Icon>
    </a>
    <DropdownMenu slot="list">
    <DropdownItem name="ownSpace">个人中心</DropdownItem>
    <DropdownItem name="loginout" divided>退出登录</DropdownItem>
    </DropdownMenu>
    </Dropdown>
    <Avatar :src="avatorPath" style="background: #619fe7;margin-left: 10px;"></Avatar>
    </Row>
    </div>

    </div>

    </div>
    <!-- 框架头部 结束 -->

    <!-- 左边菜单栏 开始 -->
    <div class="framework-sider" :style="{ shrink?'60px':'200px', overflow: shrink ? 'visible' : 'hidden'}">
    <div class="navicon-con">
    <Button type="text" @click="toggleClick" :style="{transform: 'rotateZ(' + (this.shrink ? '-90' : '0') + 'deg)'}">
    <Icon type="navicon" size="28"></Icon>
    </Button>
    </div>



    <hr-shrinkable-menu class="shinkable-menu" :shrink="shrink" :menuList="menuList" :icon-size="14" :open-names="openedSubmenuArr" @on-change="handleSubmenuChange"></hr-shrinkable-menu>
    </div>
    <!-- 左边菜单栏 结束 -->

    <div class="framework-tags" :style="{left: shrink?'60px':'200px'}">
    <hr-top-tags :pageTagsList="pageTagsList"></hr-top-tags>
    </div>

    <!-- 内容 开始 -->
    <div class="framework-content" :style="{left: shrink?'60px':'200px'}" data-role='page'>
    <div class="single-page">
    <keep-alive :include="cachePage">
    <router-view></router-view>
    </keep-alive>
    </div>
    </div>
     
    <!-- 内容 结束 -->
     
    </div>
    </template>

    <script>
    import util from "@/libs/util.js";
    import breadcrumbNav from "@/hr-components/breadcrumb/breadcrumb-nav.vue";
    import shrinkableMenu from "@/hr-components/menu/hr-shrinkable-menu.vue";
    import fullScreen from "@/hr-components/full-screen/fullscreen.vue";
    import topTags from "@/hr-components/tags-opened/hr-top-tags.vue";
    import lockScreen from "@/hr-components/lockscreen/lockscreen.vue";
    import hrSearch from "@/hr-components/search/search.vue";
    import sea from "@/hr-components/search/sea.vue";
    import messageTip from "@/hr-components/message-tip/message-tip.vue";
    import Cookies from "js-cookie";
    import http from "@/libs/http";
    import api from "@/libs/api";

    export default {
    components: {
    breadcrumbNav,
    "hr-shrinkable-menu": shrinkableMenu,
    "hr-top-tags": topTags,
    fullScreen,
    lockScreen,
    messageTip,
    "hr-search": hrSearch,
    sea
    },
    data() {
    return {
    shrink: false,
    openedSubmenuArr: this.$store.state.app.openedSubmenuArr,
    isFullScreen: false,
    name: "",
    avatorPath: "",
    searchItem: ""
    };
    },
    computed: {
    menuList() {
    return this.$store.state.app.menuList;
    },
    currentPath() {
    return this.$store.state.app.currentPath; // 当前面包屑数组
    },
    pageTagsList() {
    return this.$store.state.app.pageOpenedList; // 打开的页面的页面对象
    },

    //页面缓存
    cachePage() {
    return this.$store.state.app.cachePage;
    },
    mesCount() {
    return this.$store.state.app.messageCount;
    }
    },
    mounted() {
    this.init();
    this.changeScroll();
    const ws = new WebSocket("ws://192.168.199.107:8090/test");
    const _this = this;
    ws.onmessage = function(msg) {
    _this.$Notice.open({
    title: "Notification title",
    desc: msg.data,
    duration: 2
    });
    };
    },
    methods: {
    changeScroll() {
    $(".framework-content").niceScroll({
    cursorcolor: "#FFFF00", // 改变滚动条颜色,使用16进制颜色值
    cursoropacitymin: 0, // 当滚动条是隐藏状态时改变透明度, 值范围 1 到 0
    cursoropacitymax: 1, // 当滚动条是显示状态时改变透明度, 值范围 1 到 0
    cursor "8px", // 滚动条的宽度,单位:便素
    cursorborder: "1px solid #fff", // CSS方式定义滚动条边框
    cursorborderradius: "0px", // 滚动条圆角(像素)
    horizrailenabled: false,
    autohidemode: "scroll"
    });
    },
    changeScroll1() {
    $(".framework-sider").niceScroll({
    cursorcolor: "#000000", // 改变滚动条颜色,使用16进制颜色值
    cursoropacitymin: 0, // 当滚动条是隐藏状态时改变透明度, 值范围 1 到 0
    cursoropacitymax: 1, // 当滚动条是显示状态时改变透明度, 值范围 1 到 0
    cursor "8px", // 滚动条的宽度,单位:便素
    cursorborder: "1px solid #fff", // CSS方式定义滚动条边框
    cursorborderradius: "0px", // 滚动条圆角(像素)
    autohidemode: "scroll",
    horizrailenabled: false,
    railpadding: {
    top: 50,
    right: 0,
    left: 0,
    bottom: 0
    }
    });
    },
    // changeScroll(){
    // debugger
    // $(".").niceScroll();
    // },
    init() {
    this.changeScroll();
    this.changeScroll1();
    this.getHeadUrl();
    let pathArr = util.setCurrentPath(this, this.$route.name);
    this.$store.commit("updateMenulist");

    //判断是否有二级菜单,如果是,那么就记录打开的菜单路由
    if (pathArr.length >= 2) {
    this.$store.commit("addOpenSubmenu", pathArr[1].name);
    }
    this.name = Cookies.get("name");
    this.checkTag(this.$route.name);
    },
    async getHeadUrl() {
    let params = {};
    if (Cookies.get("head")) {
    params.picture = Cookies.get("head");
    const res = await http.get(api.getPictureUrl, params);
    if (res.code === 200) {
    this.avatorPath = res.data;
    } else {
    this.avatorPath =
    "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3448484253,3685836170&fm=27&gp=0.jpg";
    }
    } else {
    this.avatorPath =
    "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3448484253,3685836170&fm=27&gp=0.jpg";
    }
    },
    handleClickUserDropdown(name) {
    if (name === "ownSpace") {
    util.openNewPage(this, "ownspace_index");
    this.$router.push({
    name: "ownspace_index"
    });
    } else if (name === "loginout") {
    // 退出登录
    this.$store.commit("logout", this);
    this.$store.commit("clearOpenedSubmenu");
    this.$router.push({
    name: "login"
    });
    }
    },
    handleSubmenuChange(val) {
    // this.$Message.success(val);
    this.changeScroll();
    this.changeScroll1();
    console.log(val);
    },
    toggleClick() {
    this.shrink = !this.shrink;
    },
    checkTag(name) {
    let openpageHasTag = this.pageTagsList.some(item => {
    if (item.name === name) {
    return true;
    }
    });
    if (!openpageHasTag) {
    // 解决关闭当前标签后再点击回退按钮会退到当前页时没有标签的问题
    util.openNewPage(
    this,
    name,
    this.$route.params || {},
    this.$route.query || {}
    );
    }
    },
    fullscreenChange(isFullScreen) {
    console.log(isFullScreen);
    }
    },
    watch: {
    $route(to) {
    this.$store.commit("setCurrentPageName", to.name);
    let pathArr = util.setCurrentPath(this, to.name);

    if (pathArr.length > 2) {
    this.$store.commit("addOpenSubmenu", pathArr[1].name);
    }
    this.checkTag(to.name);
    }
    },
    created() {
    // 显示打开的页面的列表
    this.$store.commit("setOpenedList");
    }
    };
    </script>

         

  • 相关阅读:
    删除指定日期的文件
    pytorch加载数据集
    pytorch ResNet
    pytorch GoogLeNet
    pytorch实现VGG
    pytorch训练AlexNet
    序列化.Net对象到JSON
    c#对象序列化 用来保存对象数据
    Wpf设置listview样式
    wpf listview添加自增序号
  • 原文地址:https://www.cnblogs.com/wangyage/p/8953155.html
Copyright © 2011-2022 走看看