如何在vue中显示从脚本到模板的列表数据?

How to display list data from script to template in vue?

我有在MySQL上显示主要table数据的功能。我想通过与教员 table 的 id 进行比较来显示该专业列表的类型,如下所示。我在 console.log 上显示了它,如何在模板上显示它?谢谢

模板标签

<td>
{{ inputText }}
</td>

脚本标签

data() {
return {
    majors:[],
    faculties:[],
    form: new Form({
        major_id:'',
        major_code:'',
        major_name:'',
        major_faculty:'',
        major_status: '',
    }),
    inputText: '',
  };
},
computed: {
 filterFaculty() {
    for(let i in this.majors) {
        this.faculties.forEach((element) => {
            if(element.faculty_code==this.majors[i].major_faculty) {
                this.inputText=element.faculty_name;
            }else {
                return '-';
            }
        });
     }
  }
},
mounted() {
  this.fetchFaculties();
  this.fetchMajors();
},
methods: {
  fetchFaculties(page_url) {
    let vm = this;
    page_url = '../../api/admin/edu-faculty/faculty/faculty';
    fetch(page_url)
    .then(res => res.json())
    .then(res => {
        this.faculties = res.data;
    })
    .catch(err => console.log(err));
},
fetchMajors(page_url) {
    let vm = this;
    page_url = '../../api/admin/edu-major/major/'+this.currentEntries+'?page='+this.pagination.current_page;
    fetch(page_url)
    .then(res => res.json())
    .then(res => {
        this.majors = res.data;
        this.pagination = res.meta;
    })
    .catch(err => console.log(err));
  },
 }

I've found solution for problem

脚本标签

methods: {
   filterFaculty(major) {
      const faculty = this.faculties.find((fac) => fac.faculty_code === major.major_faculty);
        return faculty.faculty_name;
    },
}

模板标签

<td>
   {{ filterFaculty(major) }}
 </td>