小编Rap*_*des的帖子

为Typescript编写的Vue组件生成d.ts文件

我是 Vue 的新手,我想学习如何创建组件并将包发布到 NPM。所以,我的想法是创建 Vue (typescript) + Vuetify 可重用组件,并在我拥有的任何其他项目中从 NPM 安装它们。我可以在 vue.js 项目中成功导入我的 HelloWorld 组件,但是当我尝试在 Vue ts 项目中导入时,我收到以下错误:

'找不到模块 'sastify' 的声明文件。'/home/raphael/tester-ts/node_modules/sastify-nv/dist/sastify.common.js' 隐式有一个 'any' 类型。尝试npm install @types/sastify-nv它是否存在或添加一个新的声明 (.d.ts) 文件,其中包含declare module 'sastify-nv';

如何生成与我的 JS 项目类似的 .d.ts?

我的项目树是:

?? babel.config.js
??? package.json
??? postcss.config.js
??? README.md
??? src
?   ??? components
?   ?   ??? HelloWorld
?   ?       ??? HelloWorld.vue
?   ??? sastify.js
??? tsconfig.json
??? tslint.json
??? yarn.lock
Run Code Online (Sandbox Code Playgroud)

包.json:

{
  "name": "sastify-nv",
  "version": "0.1.6",
  "private": false,
  "scripts": {
    "serve": "vue-cli-service …
Run Code Online (Sandbox Code Playgroud)

typescript vue.js vuetify.js .d.ts

16
推荐指数
1
解决办法
8232
查看次数

如何分离firestore监听器

我是FireStore的新手.我创建了一个ListenerRegistration来更新我的Recycler View.我知道我的实现可能并不完美,但每次我的活动被破坏时,我的应用程序都会在此监听器内的行上引发错误.我不知道为什么,但是mt registration.remove()在destroy之前或者finish()活动之后都没有工作.有人可以帮忙吗?

public class MainActivity extends AppCompatActivity {

  private ListenerRegistration registration;
  private com.google.firebase.firestore.Query query;

  private void requestPacienteList(){

    FirebaseFirestore db = FirebaseFirestore.getInstance();
    progress.setVisibility(View.VISIBLE);
    query = db.collection("Hospital");
    registration = query.addSnapshotListener(new EventListener<QuerySnapshot>() {

        @Override
        public void onEvent(QuerySnapshot documentSnapshots, FirebaseFirestoreException e) {
            for(DocumentSnapshot documentSnapshot : documentSnapshots){

                if(documentSnapshot.get("nome").equals("Santa Clara")){

                    hospital = documentSnapshot.toObject(Hospital.class);
                    hospital.setHospitalDocumentKey(documentSnapshot.getId());
                    FirebaseFirestore db = FirebaseFirestore.getInstance();

                    db.collection("Hospital")
                            .document(hospital.getHospitalDocumentKey())
                            .collection("Pacientes")
                            .addSnapshotListener(new EventListener<QuerySnapshot>() {

                                 @Override
                                public void onEvent(QuerySnapshot documentSnapshots, FirebaseFirestoreException e) {

                                    homeModelList.clear();
                                    for(DocumentSnapshot documentSnapshot : documentSnapshots){

                                        final Paciente paciente = documentSnapshot.toObject(Paciente.class);
                                        paciente.setPacienteKey(documentSnapshot.getId());
                                        FirebaseFirestore db …
Run Code Online (Sandbox Code Playgroud)

android google-cloud-firestore

8
推荐指数
2
解决办法
6390
查看次数

将 FireStore 集合映射到 Java POJO

我正在使用 FireStore 数据库,我想知道如何将这些集合从“Hospital/DcbtizNr0ADNNnd0evlN”转换为 Java 对象?我的意思是,我如何搜索(使用 1 个查询)特定医院并将其所有文档和集合映射到一个 java 对象?

这是我的数据库结构

Pacientes/Fichas/Profissionais 遵循几乎相同的结构:

在此处输入图片说明

android google-cloud-firestore

4
推荐指数
1
解决办法
4322
查看次数