为什么import store from ‘./store‘和 ‘./store/index‘一样

简介: 为什么import store from ‘./store‘和 ‘./store/index‘一样

import store from './store'

这种方式假定在当前文件所在目录下有一个名为store的文件(可以是JavaScript或TypeScript文件,取决于你的项目配置)。当你只导入目录路径时,默认会查找该目录下的index.jsindex.ts文件作为入口

比如这样的结构

- src
  - store
    - index.js
    - ...
- ...

那么import store from './store'将会导入store目录下的index.js文件导出的内容。

import store from './store/index'

这种方式直接指定了要导入的文件路径./store/index,会导入store目录下的index.js文件的内容。

这两种方式会导入相同的内容,因为在一个目录中,通常只会有一个index.js文件作为入口,所以即使你不写index它也会默认去找到index入口文件

相关文章
|
2月前
|
编解码 供应链 数据安全/隐私保护
2023 年如何将您的应用提交到 App Store
2023 年如何将您的应用提交到 App Store
|
2月前
|
编解码 供应链 数据安全/隐私保护
如何将您的应用提交到 App Store
如何将您的应用提交到 App Store
|
开发者
ipa上传到app store的方法
假如你没有mac电脑,将ipa上传到苹果开发者中心,生成构建版本在以前是一个比较麻烦的活,但是现在有现成的免费工具可以将ipa上传到苹果开发者中心,并生成构建版本。
|
数据安全/隐私保护 iOS开发
ipa上传到APP store
在itunes中创建程序 打开 https://itunesconnect.apple.com/(membercenter中也可以找到)选择"Manage Your Applications"
|
JavaScript
Object.assign(this.$data, this.$options.data())-vue清空数据
Object.assign(target,...source)是es6新增的方法,可以合并对象,用于将所有可枚举属性的值从一个或多个源对象复制到目标对象,它将返回目标对象,target:目标对象,source:源对象,通过Object.assign方法,把source合并给target,如果目标对象中的属性名与源对象中的属性名相同时,则属性将被源对象中的属性覆盖,然后返回target对象;
164 0
this.counter$ = store.select(fromExample.getCounterCounter);
this.counter$ = store.select(fromExample.getCounterCounter);
85 0
this.counter$ = store.select(fromExample.getCounterCounter);
|
存储
使用 selector 从 SAP Spartacus state 里读取 Cart 数据
使用 selector 从 SAP Spartacus state 里读取 Cart 数据
123 0
使用 selector 从 SAP Spartacus state 里读取 Cart 数据
this.counter$ = store.select(fromExample.getCounterCounter)之后马上subscribe
this.counter$ = store.select(fromExample.getCounterCounter)之后马上subscribe
67 0
this.counter$ = store.select(fromExample.getCounterCounter)之后马上subscribe
Pinia的Store运行时定义ID
Pinia的Store运行时定义ID
457 0