Rychou / mpvue-vant

mpvue中无缝接入Vant Weapp组件库,所有组件均可使用。
406 stars 68 forks source link

field问题求助 #45

Closed taoxueweilong closed 5 years ago

taoxueweilong commented 5 years ago

field组件在页面中显示不出来,引入的路径名称都问题,其它组件可以正常显示,filed组件有地方内能够打印到信息,但是有地方就没有比如beforeCreate这个函数就没有被调用,请教这个是怎么导致的? 代码如下 引入

usingComponents: {
        'button': './../../static/components/button/index',
        'van-cell-group': './../../static/components/cell-group/index',
        'van-cell': './../../static/components/cell/index',
        'van-field ': './../../static/components/field/index'
      }
<template>
  <van-cell-group>
      <van-field
        value="username"
        required
        clearable
        label="用户名"
        placeholder="请输入用户名"
      />

      <van-field
        value="password"
        type="password"
        label="密码"
        placeholder="请输入密码"
        required
      />
    </van-cell-group>
</template>

期望的效果是输入框可以正常显示出来

Rychou commented 5 years ago

field组件无法正常显示吗? 尝试重新编译了吗?

taoxueweilong commented 5 years ago

是这样的, 重新编译或者重启电脑都不解决问题

taoxueweilong commented 5 years ago

引入的代码是这样的

usingComponents: {
        'button': './../../static/components/button/index',
        'van-cell-group': './../../static/components/cell-group/index',
        'van-cell': './../../static/components/cell/index',
        'van-field ': './../../static/components/field/index'
      }
Rychou commented 5 years ago

引入是在页面的main.json配置文件里引入的吗? 不用cell-group 单独用field能显示出来吗?

taoxueweilong commented 5 years ago

在定义路由的地方引入的,路由组件用的是mpvue-router-patch,同样的方式其它组件能正常显示

// 我的-订货单位管理-查看、编辑、新增详细信息
  {
    path: '/pages/mine/orderingUnit/operate',
    name: 'mine_orderingUnit_operate',
    config: {
      enablePullDownRefresh: false,
      navigationBarTitleText: '订货单位查看',
      usingComponents: {
        'button': './../../static/components/button/index',
        'van-cell-group': './../../static/components/cell-group/index',
        'van-cell': './../../static/components/cell/index',
        'van-field ': './../../static/components/field/index'
      }
    }
  },
taoxueweilong commented 5 years ago

单独使用也不显示

Rychou commented 5 years ago

这个路由组件我没用过,我是直接在页面的main.json文件中配置的,控制台有没有报错信息呢?

taoxueweilong commented 5 years ago

没有呢

taoxueweilong commented 5 years ago

局部引入的删除,然后全局引入(在main.js中引入编译后在dist文件夹的app.json中也有) button能正常显示,但是field就不行

"usingComponents": {
    "van-toast": "./static/components/toast/index",
    "van-icon": "./static/components/icon/index",
    "van-button": "./static/components/button/index",
    "van-popup": "./static/components/popup/index",
    "van-field ": "./static/components/field/index"
  },
<van-button>button</van-button>
    <van-field
      value="username"
      required
      clearable
      label="用户名"
      placeholder="请输入用户名"
    />

    <van-field
      value="password"
      type="password"
      label="密码"
      placeholder="请输入密码"
      required
    />
Rychou commented 5 years ago

这就比较迷了,,

"usingComponents": {
    "van-toast": "./static/components/toast/index",
    "van-icon": "./static/components/icon/index",
    "van-button": "./static/components/button/index",
    "van-popup": "./static/components/popup/index",
    "van-field ": "./static/components/field/index", //加个逗号试试?
  },