3. 指令 -- Highway MVVM

本文详细介绍了Highway前端框架中的各种指令用法,包括内建指令如数据绑定、事件绑定等,以及如何自定义指令。提供了丰富的示例帮助理解。

3-1. 内建

3-1-1. hi-bind

元素innerHTML绑定

<!-- examples/directives/bind.html -->

<div id="app">
  <input type="text" hi-value="user.name"/>
  <div hi-bind="user.name">{{user.name}}</div>
</div>

const app = new Highway({
  $el: $('#app'),
  $scope: {
    user: {
      name: 'highway'
    }
  }
});

3-1-2. hi-value

表单组件的值绑定

  1. text

    <!-- examples/directives/value.html -->
    
    <input type="text" hi-value="user.name">
  2. password

    <!-- examples/directives/value.html -->
    
    <input type="password" hi-value="user.password">
  3. number

    <!-- examples/directives/value.html -->
    
    <input type="number" hi-value="user.income">
  4. tel

    <!-- examples/directives/value.html -->
    
    <input type="tel" hi-value="user.amount">
  5. textarea

    <!-- examples/directives/value.html -->
    
    <textarea hi-value="user.description"></textarea>
  6. select

    <!-- examples/directives/value.html -->
    
    <select hi-value="user.city">
     <option value="shanghai">shanghai</option>
     <option value="guangzhou">guangzhou</option>
     <option value="shenzhen">shenzhen</option>
    </select>
  7. radio

    <!-- examples/directives/value.html -->
    
    <input name="sex" type="radio" value="male" hi-value="user.sex"> male
    <input name="sex" type="radio" value="female" hi-value="user.sex"> female
  8. checkbox

    <!-- examples/directives/value.html -->
    
    <input name="hobbies" type="checkbox" value="sports" hi-value="user.hobbies"> sports
    <input name="hobbies" type="checkbox" value="games" hi-value="user.hobbies"> games
    <input name="hobbies" type="checkbox" value="reading" hi-value="user.hobbies"> reading

    checkbox的绑定值是一个数组,如上,选中sports, games, 得到hobbies值为[‘sports’, ‘games’]

3-1-3. hi-on

事件绑定, 格式hi-on:event=”handler”,支持所有的DOM事件

触发时handler获得

  • $el: 触发元素
  • $ev: window.event事件
<!-- examples/directives/on.html -->

<div id="app">
  <button id="btn" hi-on:click="clickMe">clickMe</button>
</div>

const app = new Highway({
  $el: $('#app'),
  clickMe($el, $ev) {
    console.log(`element id is ${$el.attr('id')}, event type is ${$ev.type}`)
  }
});

3-1-4. hi-show

显示绑定,显示元素当属性值为true

<!-- examples/directives/show.html -->

<div id="app">
  <div hi-show="see">you can see me</div>
  <input name="show" type="radio" value="1" hi-value="see" checked> show
  <input name="show" type="radio" value="0" hi-value="see"> hide
</div>

false、’false’、”、’0’、null、undefined、0均被判断为boolean false

3-1-5. hi-hide

隐藏绑定,显示元素当属性值为true

<!-- examples/directives/hide.html -->

<div id="app">
  <div hi-hide="see">you can see me</div>
  <input name="show" type="radio" value="1" hi-value="see" checked> hide
  <input name="show" type="radio" value="0" hi-value="see" > show
</div>

false、’false’、”、’0’、null、undefined、0均被判断为boolean false

3-1-6. hi-if

插入元素当属性值为true,如为false将被移除

<!-- examples/directives/if.html -->

<div id="app">
  <div hi-if="ifMe">
    <p>you can see me</p>
    <my-component></my-component>
  </div>
  <input name="if" type="radio" value="true" hi-value="ifMe" checked> render
  <input name="if" type="radio" value="false" hi-value="ifMe"> destroy
</div>

<script id="template" type="text/template">
  <div>i am {{name}}</div>
</script>

const myComponent = Highway.extend({
  $template: $('#template').html(),
  $scope: {
    name: 'myComponent'
  },
  $mount() {
    console.log('>>>::myComponent rendered');
  },
  $unmount() {
    console.log('>>>::myComponent destroyed');
  }
});

const app = new Highway({
  $el: $('#app'),
  $components: {
    'my-component': myComponent
  }
});

false、’false’、”、’0’、null、undefined、0均被判断为boolean false

hi-if会触发局部编译/销毁过程,同时移除元素

hi-show/hi-hide仅会隐藏元素,并不会移除

3-1-7. hi-repeat

重复绑定

<!-- examples/directives/repeat.html -->

<div id="app">
  <ul>
    <li hi-repeat="user in data.users" hi-data:id="{{user.id}}">
      <p>{{user.name}}</p>
    </li>
  </ul>
  <button hi-on:click="change">change</button>
</div>

const app = new Highway({
  $el: $('#app'),
  $scope: {
    data: {
      users: [
        {
          'id': '001',
          'name': 'jackey'
        },
        {
          'id': '002',
          'name': 'suse'
        },
        {
          'id': '003',
          'name': 'ann'
        },
      ]
    }
  },
  change() {
    this.$set('data.users[2].name', 'highway');
  }
});

repeat指令会触发局部编译,同时临时伸展作用域

3-1-8. hi-src

元素src绑定

<!-- examples/directives/src.html -->

<div id="app">
  <img hi-src="imageUrl" width="100%"/>
</div>

3-1-9. hi-href

元素href绑定

<!-- examples/directives/href.html -->

<div id="app">
  <a hi-href="link">click me</a>
</div>

3-1-10. hi-data

元素data属性绑定, hi-data:dataProp=”prop”

<!-- examples/directives/data.html -->

<div id="app">
  <button hi-on:click="clickMe" hi-data:name="name">clickMe</button>
</div>

const app = new Highway({
  $el: $('#app'),
  $scope: {
    name: "highway"
  },
  clickMe($el) {
    alert($el.data('name'));
  }
});

3-1-11. hi-enable

元素enable绑定

<!-- examples/directives/enable.html -->

<div id="app">
  <button hi-enable="enable" hi-on:click="clickMe">button</button>
  <input name="enable" type="radio" value="1" hi-value="enable" > enable
  <input name="enable" type="radio" value="0" hi-value="enable"> disable
</div>

const app = new Highway({
  $el: $('#app'),
  clickMe() {
    alert(1)
  }
});

3-1-12. hi-disable

元素disable绑定

<!-- examples/directives/disable.html -->

<div id="app">
  <button hi-enable="disable" hi-on:click="clickMe">button</button>
  <input name="disable" type="radio" value="1" hi-value="disable" checked> disable
  <input name="disable" type="radio" value="0" hi-value="disable"> enable
</div>

const app = new Highway({
  $el: $('#app'),
  clickMe() {
    alert(1)
  }
});

3-1-13. hi-readonly

<!-- examples/directives/readonly.html -->

<div id="app">
  <p>{{name}}</p>
  <input type="text" hi-readonly="readonly" hi-value="name"/>
  <input name="readonly" type="radio" value="1" hi-value="readonly" checked> readonly
  <input name="readonly" type="radio" value="0" hi-value="readonly" > editable
</div>

const app = new Highway({
  $el: $('#app'),
  $scope: {
    name: 'highway'
  }
});

3-1-14. hi-attr

元素属性值绑定。hi-attr:domAttr=”prop”,任意绑定指定DOM属性值。

<!-- examples/directives/attr.html -->

<div id="app">
  <img hi-attr:src="imageUrl" hi-attr:width="width" />
</div>

const app = new Highway({
  $el: $('#app'),
  $scope: {
    width: '50%',
    imageUrl: './dog.jpeg'
  }
});

3-1-15. hi-css

元素css值绑定。hi-css:css=”prop”。

<!-- examples/directives/css.html -->

<div id="app">
  <div hi-css:background-color="{{bgColor}}">div</div>
</div>

const app = new Highway({
  $el: $('#app'),
  $scope: {
    bgColor: 'red'
  }
});

3-1-16. hi-class

元素样式值绑定。hi-class:unique=”obj[prop]”,遇多个中间以;分割

3-1-16-1. 直接量
3-1-16-1-1. 单个
<div hi-class="direct.bgColor">direct-0</div>
<div hi-class="direct.fontSize">direct-1</div>
3-1-16-1-2. 组合

中间以”,”号分隔,如使用多个hi-class指令,需指定uniqueid,例如hi-class:bgColor=”direct.bgColor”, uniqueid=”bgColor”

<div hi-class:bgColor="direct.bgColor", hi-class:fontSize="direct.fontSize">direct-2</div>
<div hi-class="direct.bgColor, direct.fontSize">direct-3</div>
3-1-16-2. 映射
3-1-16-2-1. 单个
<div hi-class="{'red': 'bg-red', 'green': 'bg-green'}[mapping.bgColor];">mapping-0</div>
<div hi-class="{'fs20': 'fs-20', 'fs40': 'fs-40'}[mapping.fontSize]">mapping-1</div>
3-1-16-2-2. 组合

中间以”,”号分隔,如使用多个hi-class指令,需指定uniqueid。

<div hi-class:bgColor="{'red': 'bg-red', 'green': 'bg-green'}[mapping.bgColor];" hi-class:bgColor="{'red': 'bg-red', 'green': 'bg-green'}[mapping.bgColor];">mapping-2</div>

<div hi-class="{'red': 'bg-red', 'green': 'bg-green'}[mapping.bgColor];{'fs20': 'fs-20', 'fs40': 'fs-40'}[mapping.fontSize]">mapping-3</div>
3-1-16-3. 示例
<!-- examples/directives/class.html -->

<style type="text/css">
  .bg-red {
    background-color: red;
  }

  .bg-green {
    background-color: green;
  }

  .fs-20 {
    font-size: 20px;
  }

  .fs-40 {
    font-size: 40px;
  }
</style>

<div id="app">
  <p>>>> direct - single</p>
  <div hi-class="direct.bgColor">direct-0</div>
  <div hi-class="direct.fontSize">direct-1</div>

  <p>>>> direct - combi</p>
  <div hi-class:bgColor="direct.bgColor", hi-class:fontSize="direct.fontSize">direct-2</div>
  <div hi-class="direct.bgColor, direct.fontSize">direct-3</div>
  <hr>

  <p>>>> mapping - single</p>
  <div hi-class="{'red': 'bg-red', 'green': 'bg-green'}[mapping.bgColor];">mapping-0</div>
  <div hi-class="{'fs20': 'fs-20', 'fs40': 'fs-40'}[mapping.fontSize]">mapping-1</div>

  <p>>>> mapping - combi</p>
  <div hi-class:bgColor="{'red': 'bg-red', 'green': 'bg-green'}[mapping.bgColor];" hi-class:bgColor="{'red': 'bg-red', 'green': 'bg-green'}[mapping.bgColor];">mapping-2</div>
  <div hi-class="{'red': 'bg-red', 'green': 'bg-green'}[mapping.bgColor];{'fs20': 'fs-20', 'fs40': 'fs-40'}[mapping.fontSize]">mapping-3</div>

</div>

const app = new Highway({
  $el: $('#app'),
  $scope: {
    mapping: {
      bgColor: 'red',
      fontSize: 'fs40'
    },
    direct: {
      bgColor: 'bg-red',
      fontSize: 'fs-20'
    }
  }
});

3-2. 自定义

自定义指令为一个工厂函数

3-2-1. 入参

参数

  • $el: 指定所在的DOM元素,为一个jQuery对象
  • arg:hiattr:title="myTitle",arg = ‘title’
  • exp:hiattr:title="myTitle",exp = ‘myTitle’
  • scope:hiattr:title="myTitle",scope.$get(‘myTitle’)获取当前作用域中myTitle值。
  • $ctx: 上下文, 当前视图(子视图)实例this值
// 通过bg-color指令设置元素背景颜色 <div bg-color="#ff0000"></div>
const bgColor = function ({$el, $exp}) {
    $el.css('background-color', $exp)
};

3-2-2. 出参

  • $mount:生命周期函数,挂载时调用。
  • $unmount:生命周期函数,卸载时调用

3-2-3. 全局

全局有效,通过Highway.directive指定

Highway.directive('bg-color', bgColor);

3-2-4. 局部

指定视图中有效,通过View.$directives指定

3-2-5. 示例

自定义指令,指令格式为hi-bgcolor=”color”

<!-- examples/directives/customized.html -->

<div id="app">
  <div hi-bgcolor="#ff0000">highway</div>
</div>

const bgColor = function ({$el, $exp}) { //$ctx, $el, $arg, $exp
  $el.css('background-color', $exp);
};

//Highway.directive('hi-bgcolor', bgColor);

const app = new Highway({
  $el: $('#app'),
  $directives: {
    'hi-bgcolor': bgColor
  }
});

3-2-3. 指令模式

Highway中预置了指令模式,快速构建您的自定义指令,可通过Highway.directive.pattern指定

接收4个参数,依次为

  • $exp:表达式
  • $scope:作用域
  • $ctx:上下文
  • $updater:更新函数
<!-- examples/directives/pattern.html -->

<div id="app">
  <div hi-bgcolor="bgColor">highway</div>
</div>

const bgColor = function ({$el, $exp, $scope, $ctx}) { //$ctx, $el, $arg, $exp
  return Highway.directive.pattern($exp, $scope, $ctx, function ({newVal, secure}) {
    newVal = secure ? Highway.utils.secureHtml(newVal) : newVal;
    $el.css('background-color', newVal);
  });
};

//Highway.directive('hi-bgcolor', bgColor);

const app = new Highway({
  $el: $('#app'),
  $scope: {
    bgColor: 'red'
  },
  $directives: {
    'hi-bgcolor': bgColor
  }
});
(.venv) PS C:\Users\chen4\PycharmProjects\pythonProject1\.venv\Scripts> pip install gluonnlp Collecting gluonnlp Using cached gluonnlp-0.10.0.tar.gz (344 kB) Preparing metadata (setup.py) ... done Requirement already satisfied: numpy>=1.16.0 in c:\users\chen4\pycharmprojects\pythonproject1\.venv\lib\site-packages (from gluonnlp) (1.26.4) Collecting cython (from gluonnlp) Using cached cython-3.1.2-cp312-cp312-win_amd64.whl.metadata (6.0 kB) Requirement already satisfied: packaging in c:\users\chen4\pycharmprojects\pythonproject1\.venv\lib\site-packages (from gluonnlp) (24.1) Using cached cython-3.1.2-cp312-cp312-win_amd64.whl (2.7 MB) Building wheels for collected packages: gluonnlp DEPRECATION: Building &#39;gluonnlp&#39; using the legacy setup.py bdist_wheel mechanism, which will be removed in a future version. pip 25.3 will enforce this behaviour change. A possib le replacement is to use the standardized build interface by setting the `--use-pep517` option, (possibly combined with `--no-build-isolation`), or adding a `pyproject.toml` file to the source tree of &#39;gluonnlp&#39;. Discussion can be found at https://github.com/pypa/pip/issues/6334 Building wheel for gluonnlp (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [136 lines of output] C:\Users\chen4\PycharmProjects\pythonProject1\.venv\Lib\site-packages\setuptools\__init__.py:92: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated. !! ******************************************************************************** Requirements should be satisfied by a PEP 517 installer. If you are using pip, you can try `pip install --use-pep517`. By 2025-Oct-31, you need to update your project and remove deprecated calls or your builds will no longer be supported. ******************************************************************************** !! dist.fetch_build_eggs(dist.setup_requires) running bdist_wheel running build running build_py creating build\lib.win-amd64-cpython-312\gluonnlp copying src\gluonnlp\base.py -> build\lib.win-amd64-cpython-312\gluonnlp copying src\gluonnlp\_constants.py -> build\lib.win-amd64-cpython-312\gluonnlp copying src\gluonnlp\__init__.py -> build\lib.win-amd64-cpython-312\gluonnlp creating build\lib.win-amd64-cpython-312\gluonnlp\calibration copying src\gluonnlp\calibration\collector.py -> build\lib.win-amd64-cpython-312\gluonnlp\calibration copying src\gluonnlp\calibration\__init__.py -> build\lib.win-amd64-cpython-312\gluonnlp\calibration creating build\lib.win-amd64-cpython-312\gluonnlp\data copying src\gluonnlp\data\baidu_ernie_data.py -> build\lib.win-amd64-cpython-312\gluonnlp\data copying src\gluonnlp\data\candidate_sampler.py -> build\lib.win-amd64-cpython-312\gluonnlp\data copying src\gluonnlp\data\classification.py -> build\lib.win-amd64-cpython-312\gluonnlp\data copying src\gluonnlp\data\conll.py -> build\lib.win-amd64-cpython-312\gluonnlp\data copying src\gluonnlp\data\dataloader.py -> build\lib.win-amd64-cpython-312\gluonnlp\data copying src\gluonnlp\data\dataset.py -> build\lib.win-amd64-cpython-312\gluonnlp\data copying src\gluonnlp\data\datasetloader.py -> build\lib.win-amd64-cpython-312\gluonnlp\data copying src\gluonnlp\data\glue.py -> build\lib.win-amd64-cpython-312\gluonnlp\data copying src\gluonnlp\data\intent_slot.py -> build\lib.win-amd64-cpython-312\gluonnlp\data copying src\gluonnlp\data\question_answering.py -> build\lib.win-amd64-cpython-312\gluonnlp\data copying src\gluonnlp\data\registry.py -> build\lib.win-amd64-cpython-312\gluonnlp\data copying src\gluonnlp\data\sampler.py -> build\lib.win-amd64-cpython-312\gluonnlp\data copying src\gluonnlp\data\sentiment.py -> build\lib.win-amd64-cpython-312\gluonnlp\data copying src\gluonnlp\data\stream.py -> build\lib.win-amd64-cpython-312\gluonnlp\data copying src\gluonnlp\data\super_glue.py -> build\lib.win-amd64-cpython-312\gluonnlp\data copying src\gluonnlp\data\transforms.py -> build\lib.win-amd64-cpython-312\gluonnlp\data copying src\gluonnlp\data\translation.py -> build\lib.win-amd64-cpython-312\gluonnlp\data copying src\gluonnlp\data\utils.py -> build\lib.win-amd64-cpython-312\gluonnlp\data copying src\gluonnlp\data\word_embedding_evaluation.py -> build\lib.win-amd64-cpython-312\gluonnlp\data copying src\gluonnlp\data\__init__.py -> build\lib.win-amd64-cpython-312\gluonnlp\data creating build\lib.win-amd64-cpython-312\gluonnlp\embedding copying src\gluonnlp\embedding\evaluation.py -> build\lib.win-amd64-cpython-312\gluonnlp\embedding copying src\gluonnlp\embedding\token_embedding.py -> build\lib.win-amd64-cpython-312\gluonnlp\embedding copying src\gluonnlp\embedding\__init__.py -> build\lib.win-amd64-cpython-312\gluonnlp\embedding creating build\lib.win-amd64-cpython-312\gluonnlp\initializer copying src\gluonnlp\initializer\initializer.py -> build\lib.win-amd64-cpython-312\gluonnlp\initializer copying src\gluonnlp\initializer\__init__.py -> build\lib.win-amd64-cpython-312\gluonnlp\initializer creating build\lib.win-amd64-cpython-312\gluonnlp\loss copying src\gluonnlp\loss\activation_regularizer.py -> build\lib.win-amd64-cpython-312\gluonnlp\loss copying src\gluonnlp\loss\label_smoothing.py -> build\lib.win-amd64-cpython-312\gluonnlp\loss copying src\gluonnlp\loss\loss.py -> build\lib.win-amd64-cpython-312\gluonnlp\loss copying src\gluonnlp\loss\__init__.py -> build\lib.win-amd64-cpython-312\gluonnlp\loss creating build\lib.win-amd64-cpython-312\gluonnlp\metric copying src\gluonnlp\metric\length_normalized_loss.py -> build\lib.win-amd64-cpython-312\gluonnlp\metric copying src\gluonnlp\metric\masked_accuracy.py -> build\lib.win-amd64-cpython-312\gluonnlp\metric copying src\gluonnlp\metric\__init__.py -> build\lib.win-amd64-cpython-312\gluonnlp\metric creating build\lib.win-amd64-cpython-312\gluonnlp\model copying src\gluonnlp\model\attention_cell.py -> build\lib.win-amd64-cpython-312\gluonnlp\model copying src\gluonnlp\model\bert.py -> build\lib.win-amd64-cpython-312\gluonnlp\model copying src\gluonnlp\model\bilm_encoder.py -> build\lib.win-amd64-cpython-312\gluonnlp\model copying src\gluonnlp\model\block.py -> build\lib.win-amd64-cpython-312\gluonnlp\model copying src\gluonnlp\model\convolutional_encoder.py -> build\lib.win-amd64-cpython-312\gluonnlp\model copying src\gluonnlp\model\elmo.py -> build\lib.win-amd64-cpython-312\gluonnlp\model copying src\gluonnlp\model\highway.py -> build\lib.win-amd64-cpython-312\gluonnlp\model copying src\gluonnlp\model\info.py -> build\lib.win-amd64-cpython-312\gluonnlp\model copying src\gluonnlp\model\language_model.py -> build\lib.win-amd64-cpython-312\gluonnlp\model copying src\gluonnlp\model\lstmpcellwithclip.py -> build\lib.win-amd64-cpython-312\gluonnlp\model copying src\gluonnlp\model\parameter.py -> build\lib.win-amd64-cpython-312\gluonnlp\model copying src\gluonnlp\model\sampled_block.py -> build\lib.win-amd64-cpython-312\gluonnlp\model copying src\gluonnlp\model\seq2seq_encoder_decoder.py -> build\lib.win-amd64-cpython-312\gluonnlp\model copying src\gluonnlp\model\sequence_sampler.py -> build\lib.win-amd64-cpython-312\gluonnlp\model copying src\gluonnlp\model\transformer.py -> build\lib.win-amd64-cpython-312\gluonnlp\model copying src\gluonnlp\model\translation.py -> build\lib.win-amd64-cpython-312\gluonnlp\model copying src\gluonnlp\model\utils.py -> build\lib.win-amd64-cpython-312\gluonnlp\model copying src\gluonnlp\model\__init__.py -> build\lib.win-amd64-cpython-312\gluonnlp\model creating build\lib.win-amd64-cpython-312\gluonnlp\optimizer copying src\gluonnlp\optimizer\bert_adam.py -> build\lib.win-amd64-cpython-312\gluonnlp\optimizer copying src\gluonnlp\optimizer\__init__.py -> build\lib.win-amd64-cpython-312\gluonnlp\optimizer creating build\lib.win-amd64-cpython-312\gluonnlp\utils copying src\gluonnlp\utils\files.py -> build\lib.win-amd64-cpython-312\gluonnlp\utils copying src\gluonnlp\utils\parallel.py -> build\lib.win-amd64-cpython-312\gluonnlp\utils copying src\gluonnlp\utils\parameter.py -> build\lib.win-amd64-cpython-312\gluonnlp\utils copying src\gluonnlp\utils\seed.py -> build\lib.win-amd64-cpython-312\gluonnlp\utils copying src\gluonnlp\utils\version.py -> build\lib.win-amd64-cpython-312\gluonnlp\utils copying src\gluonnlp\utils\__init__.py -> build\lib.win-amd64-cpython-312\gluonnlp\utils creating build\lib.win-amd64-cpython-312\gluonnlp\vocab copying src\gluonnlp\vocab\bert.py -> build\lib.win-amd64-cpython-312\gluonnlp\vocab copying src\gluonnlp\vocab\elmo.py -> build\lib.win-amd64-cpython-312\gluonnlp\vocab copying src\gluonnlp\vocab\subwords.py -> build\lib.win-amd64-cpython-312\gluonnlp\vocab copying src\gluonnlp\vocab\vocab.py -> build\lib.win-amd64-cpython-312\gluonnlp\vocab copying src\gluonnlp\vocab\__init__.py -> build\lib.win-amd64-cpython-312\gluonnlp\vocab creating build\lib.win-amd64-cpython-312\gluonnlp\data\batchify copying src\gluonnlp\data\batchify\batchify.py -> build\lib.win-amd64-cpython-312\gluonnlp\data\batchify copying src\gluonnlp\data\batchify\embedding.py -> build\lib.win-amd64-cpython-312\gluonnlp\data\batchify copying src\gluonnlp\data\batchify\language_model.py -> build\lib.win-amd64-cpython-312\gluonnlp\data\batchify copying src\gluonnlp\data\batchify\__init__.py -> build\lib.win-amd64-cpython-312\gluonnlp\data\batchify creating build\lib.win-amd64-cpython-312\gluonnlp\data\bert copying src\gluonnlp\data\bert\glue.py -> build\lib.win-amd64-cpython-312\gluonnlp\data\bert copying src\gluonnlp\data\bert\squad.py -> build\lib.win-amd64-cpython-312\gluonnlp\data\bert copying src\gluonnlp\data\bert\__init__.py -> build\lib.win-amd64-cpython-312\gluonnlp\data\bert creating build\lib.win-amd64-cpython-312\gluonnlp\data\corpora copying src\gluonnlp\data\corpora\google_billion_word.py -> build\lib.win-amd64-cpython-312\gluonnlp\data\corpora copying src\gluonnlp\data\corpora\large_text_compression_benchmark.py -> build\lib.win-amd64-cpython-312\gluonnlp\data\corpora copying src\gluonnlp\data\corpora\wikitext.py -> build\lib.win-amd64-cpython-312\gluonnlp\data\corpora copying src\gluonnlp\data\corpora\__init__.py -> build\lib.win-amd64-cpython-312\gluonnlp\data\corpora creating build\lib.win-amd64-cpython-312\gluonnlp\data\xlnet copying src\gluonnlp\data\xlnet\squad.py -> build\lib.win-amd64-cpython-312\gluonnlp\data\xlnet copying src\gluonnlp\data\xlnet\__init__.py -> build\lib.win-amd64-cpython-312\gluonnlp\data\xlnet creating build\lib.win-amd64-cpython-312\gluonnlp\model\train copying src\gluonnlp\model\train\cache.py -> build\lib.win-amd64-cpython-312\gluonnlp\model\train copying src\gluonnlp\model\train\embedding.py -> build\lib.win-amd64-cpython-312\gluonnlp\model\train copying src\gluonnlp\model\train\language_model.py -> build\lib.win-amd64-cpython-312\gluonnlp\model\train copying src\gluonnlp\model\train\__init__.py -> build\lib.win-amd64-cpython-312\gluonnlp\model\train running egg_info writing src\gluonnlp.egg-info\PKG-INFO writing dependency_links to src\gluonnlp.egg-info\dependency_links.txt writing requirements to src\gluonnlp.egg-info\requires.txt writing top-level names to src\gluonnlp.egg-info\top_level.txt reading manifest file &#39;src\gluonnlp.egg-info\SOURCES.txt&#39; reading manifest template &#39;MANIFEST.in&#39; warning: no files found matching &#39;*.py&#39; under directory &#39;gluonnlp&#39; warning: no previously-included files matching &#39;*&#39; found under directory &#39;tests&#39; warning: no previously-included files matching &#39;*&#39; found under directory &#39;scripts&#39; adding license file &#39;LICENSE&#39; writing manifest file &#39;src\gluonnlp.egg-info\SOURCES.txt&#39; copying src\gluonnlp\data\fast_bert_tokenizer.c -> build\lib.win-amd64-cpython-312\gluonnlp\data copying src\gluonnlp\data\fast_bert_tokenizer.pyx -> build\lib.win-amd64-cpython-312\gluonnlp\data running build_ext Compiling src/gluonnlp/data/fast_bert_tokenizer.pyx because it changed. [1/1] Cythonizing src/gluonnlp/data/fast_bert_tokenizer.pyx building &#39;gluonnlp.data.fast_bert_tokenizer&#39; extension error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for gluonnlp Running setup.py clean for gluonnlp Failed to build gluonnlp ERROR: Failed to build installable wheels for some pyproject.toml based projects (gluonnlp) 以上为安装gluonnlp的报错结果
06-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值