问题描述
我有一个任务-解析("Query1" OR "Query2") AND ("Quesy3" OR "Query4")
类型的数据
我为此使用TsPeg。一切都解决了,但是如何在Vue项目中使用库的parse()
方法呢?
简单地说,我需要提取 VueJS
中 Node.js 中可用的方法解决方法
您可以将解析器设置为import 'package:finnik_admin_mvp/constants.dart';
import 'package:finnik_admin_mvp/pages/views/news_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class MainPage extends StatefulWidget {
@override
_MainPageState createState() => _MainPageState();
}
class _MainPageState extends State<MainPage> {
int _selectedIndex = 1;
getView() {
switch (_selectedIndex) {
case 1:
{
return NewsView();
}
break;
default:
{
return Expanded(
child: Center(
child: Text('selectedIndex: $_selectedIndex'),),);
}
break;
}
}
@override
Widget build(BuildContext context) {
ScreenUtil.init(
context,height: 1080,width: 1920,);
ScreenUtil _su = ScreenUtil();
return Scaffold(
backgroundColor: kPurpuleColor,appBar: PreferredSize(
preferredSize: Size.fromHeight(
_su.setHeight(102),child: AppBar(
backgroundColor: kPurpuleColor,leadingWidth: _su.setWidth(180),actions: [
Container(
margin: EdgeInsets.only(
right: _su.setWidth(8),width: _su.setWidth(150),child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,children: [
IconButton(
icon: FaIcon(
FontAwesomeIcons.userCircle,size: _su.setWidth(37.86),onPressed: () {},IconButton(
icon: FaIcon(
FontAwesomeIcons.bars,],leading: Container(
margin: EdgeInsets.only(left: 30),child: Image.asset(
kLogoSolidPath,width: _su.setWidth(146),height: _su.setHeight(66),body: SafeArea(
child: Row(
children: [
Container(
width: 70,height: MediaQuery.of(context).size.height,child: NavigationRail(
minWidth: 50,backgroundColor: kPurpuleColor,selectedIconTheme: IconThemeData(
color: kYellowColor,size: _su.setWidth(
35,unselectedIconTheme: IconThemeData(
color: Colors.white,elevation: 3,destinations: [
NavigationRailDestination(
icon: FaIcon(
FontAwesomeIcons.home,label: Container(),NavigationRailDestination(
icon: FaIcon(
FontAwesomeIcons.newspaper,NavigationRailDestination(
icon: FaIcon(
FontAwesomeIcons.userAlt,NavigationRailDestination(
icon: FaIcon(
FontAwesomeIcons.tags,NavigationRailDestination(
icon: FaIcon(
Icons.import_export,size: 35,NavigationRailDestination(
icon: FaIcon(
FontAwesomeIcons.dollarSign,NavigationRailDestination(
icon: FaIcon(
FontAwesomeIcons.chartLine,NavigationRailDestination(
icon: FaIcon(
FontAwesomeIcons.cog,NavigationRailDestination(
icon: FaIcon(
FontAwesomeIcons.questionCircle,labelType: NavigationRailLabelType.all,selectedIndex: _selectedIndex,onDestinationSelected: (int index) {
setState(() {
_selectedIndex = index;
});
},VerticalDivider(thickness: 2,width: 2),getView(),)),);
}
}
,其中~/modules/parser.js
是vue的根目录。
然后,您只需导入并在vue文件的~/
标签中使用
<script></script>