zoukankan      html  css  js  c++  java
  • 如何让登录名嵌入到登录的地方

     <template>

    <ul class="nav-list">

     <li v-if="username=== ''" @click="logClick">登录</li>

    </ul>

    <my-dialog :is-show="isShowLogDialog" >
    <log-form @has-log="onSuccessLog"></log-form>
    </my-dialog>

    </template>

    <script>

    import LogForm from './logForm'

    export default {

    components: {
    LogForm
    },

    data () {
    return {
    isShowLogDialog: false,
    username: ''
    }
    },

    methods:{

    // 子组件用户名密码登录成功后把用户名显示在注册上,把data的数值传入username中
    onSuccessLog (data) {
    console.log(data)
    this.closeDialog ('isShowLogDialog')
    this.username = data.username
    }

    }

    }

    //子组件LogForm

    <template>

    <div class="g-form-line">
    <div class="g-form-btn">
    <a class="button" @click="onLogin">登录</a>
    </div>
    </div>

    </template>

    <script>

    methods: {
    onLogin () {
    if (!this.userErrors.status || !this.passwordErrors.status) {
    this.errorText = '部分选项未通过'
    }
    else {
    this.errorText = ''
    this.$http.get('api/login')
    .then((res) => {
    // 通过子传父的方式把res.data的数据传给has-log
    this.$emit('has-log', res.data)
    }, (error) => {
    console.log(error)
    })
    }
    }
    }

    </script>

  • 相关阅读:
    在单机Hadoop上面增加Slave
    两台机器添加信任关系
    JS Scoping and Hoisting
    SCSS(SASS、CSS)学习
    程序的内存情况
    delete-node-in-a-bst
    serialize-and-deserialize-bst
    Linux Shell脚本编程--curl命令详解
    iOS文件保存策略
    浅谈spring——spring MVC(十一)
  • 原文地址:https://www.cnblogs.com/smdb/p/8001279.html
Copyright © 2011-2022 走看看